How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • function task() {
        
        //...
    eslintrc.save();
    
        // Install npm dependencies
        if (!hasReact) {
            install(packages.dependencies, { dev: false });
            install(packages.devDependencies);
        }
    }
    
    
    /smarthead/mrm-preset mit
  • const tasks = new Listr([
        {
            title: 'Install package dependencies with Yarn',
            task: (ctx, task) => execa('yarn')
                .catch(() => {
                    ctx.yarn = false;
     
                    task.title = `${task.title} (or not)`;
                    task.skip('Yarn not available');
                })
        },
        {
            title: 'Install package dependencies with npm',
            skip: ctx => ctx.yarn !== false && 'Dependencies already installed with Yarn',
            task: (ctx, task) => {
                task.output = 'Installing dependencies...';
     
                return execa('npm', ['install'])
            }
        }
    ]);
     
    tasks.run();
    Docs
  • const tasks = new Listr([
        {
            title: 'Install package dependencies with Yarn',
            task: (ctx, task) => execa('yarn')
                .catch(() => {
                    ctx.yarn = false;
     
                    task.skip('Yarn not available, install it via `npm install -g yarn`');
                })
        },
        {
            title: 'Install package dependencies with npm',
            enabled: ctx => ctx.yarn === false,
            task: () => execa('npm', ['install'])
        }
    ]);
    Docs
  • // Imports the Google Cloud Tasks library.
    const {CloudTasksClient} = require('@google-cloud/tasks');
    
    // Instantiates a client.
    const client = new CloudTasksClient();
    
    async function quickstart() {
      // TODO(developer): Uncomment these lines and replace with your values.
      // const project = 'my-project-id';
      // const queue = 'my-appengine-queue';
      // const location = 'us-central1';
      // const payload = 'hello';
    
      // Construct the fully qualified queue name.
      const parent = client.queuePath(project, location, queue);
    
      const task = {
        appEngineHttpRequest: {
          httpMethod: 'POST',
          relativeUri: '/log_payload',
        },
      };
    
      if (payload) {
        task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64');
      }
    
      if (inSeconds) {
        task.scheduleTime = {
          seconds: inSeconds + Date.now() / 1000,
        };
      }
    
      const request = {
        parent: parent,
        task: task,
      };
    
      console.log('Sending task:');
      console.log(task);
      // Send create task request.
      const [response] = await client.createTask(request);
      const name = response.name;
      console.log(`Created task ${name}`);
    }
    quickstart();
    Docs
  • // Before running the sample:
    // - Enable the API at:
    //   https://console.developers.google.com/apis/api/tasks.googleapis.com
    // - Login into gcloud by running:
    //   `$ gcloud auth application-default login`
    // - Install the npm module by running:
    //   `$ npm install googleapis`
    
    const {google} = require('googleapis');
    const tasks = google.tasks('v1');
    
    async function main() {
      const auth = new google.auth.GoogleAuth({
        // Scopes can be specified either as an array or as a single, space-delimited string.
        scopes: ['https://www.googleapis.com/auth/tasks'],
      });
    
      // Acquire an auth client, and bind it to all future calls
      const authClient = await auth.getClient();
      google.options({auth: authClient});
    
      // Do the magic
      const res = await tasks.tasks.delete({
        // Task identifier.
        task: 'placeholder-value',
        // Task list identifier.
        tasklist: 'placeholder-value',
      });
      console.log(res.data);
    }
    
    main().catch(e => {
      console.error(e);
      throw e;
    });
    
    Docs
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples