How to use the temp.mkdirAsync function in temp

To help you get started, we’ve selected a few temp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serverless / serverless / lib / commands / ModuleInstall.js View on Github external
url[2].split('#');
      repo.repo = url[2].split('#')[0];
      repo.branch = url[2].split('#')[1];
    }

    if (url.hostname !== 'github.com' || !repo.owner || !repo.repo) {
      spinner.stop(true);
      return Promise.reject(new JawsError(
          'Must be a github url in this format: https://github.com/jaws-framework/JAWS',
          JawsError.errorCodes.UNKNOWN
      ));
    }

    let downloadUrl = 'https://github.com/' + repo.owner + '/' + repo.repo + '/archive/' + repo.branch + '.zip';

    return temp.mkdirAsync('awsm')
        .then(tempDirPath => {
          return new Promise(function(resolve, reject) {
            utils.jawsDebug(`Downloading awsm to ${tempDirPath}`);
            JawsCLI.log('Downloading aws-module ...');
            spinner.start();

            new Download({
              timeout: 30000,
              extract: true,
              strip: 1,
              mode: '755',
            })
                .get(downloadUrl)
                .dest(tempDirPath)
                .run(function(error) {
                  spinner.stop(true);
github serverless / serverless / lib / actions / ModuleInstall.js View on Github external
//TODO: support github tree URLS (branch): https://github.com/serverless/serverless/tree/cf-deploy
      if (~repo.repo.indexOf('#')) {
        url[2].split('#');
        repo.repo = url[2].split('#')[0];
        repo.branch = url[2].split('#')[1];
      }

      if (url.hostname !== 'github.com' || !repo.owner || !repo.repo) {
        spinner.stop(true);
        return BbPromise.reject(new SError('Must be a github url in this format: https://github.com/serverless/serverless', SError.errorCodes.UNKNOWN));
      }

      let downloadUrl = 'https://github.com/' + repo.owner + '/' + repo.repo + '/archive/' + repo.branch + '.zip';

      return temp.mkdirAsync('module')
          .then(function(tempModulePath) {
            return new BbPromise(function(resolve, reject) {
              SCli.log('Downloading module ...');
              spinner.start();

              new Download({
                timeout: 30000,
                extract: true,
                strip: 1,
                mode: '755',
              }).get(downloadUrl)
                .dest(tempModulePath)
                .run(function(error) {
                  spinner.stop(true);
                  if (error) {
                    return BbPromise.reject(new SError('Module Download and installation failed: ' + error, SError.errorCodes.UNKNOWN));