Executes eslint for a project, asynchronously.
@param {boolean|ESLintOptions|undefined} [options=undefined] The options to use. If a boolean, options will be { fail: true|false }.
@returns {Promise<boolean>} A promise
507879
function eslint(options) {
  if (typeof options === 'boolean') {
    options = { fail: options }
  }
  options = { ...new ESLintOptions(), ...options }

  return new Promise((resolve, reject) => {
    const args = generateArguments(options)
    const child = spawn('node', args, { stdio: options.stdio, cwd: path.resolve(options.appRootPath || getRootPath()) })

    function handleError(error) {
      if (options.fail === false) {
        resolve(false)
      } else {
        reject(cleanupError(error))
      }
    }

    child.on('error', handleError)

    child.on('exit', error => {
      if (error) {
        handleError(error)
      } else {
        resolve(true)
      }
    })
  })
}
821505
function execute(/*args*/) {

  const command = prepare_command(arguments);
  ensure_executable(command);
  create_result_file_name(command);

  return platform.execute(command)
  //Handle Results
  .then(() => new Promise((resolve,reject) => {

    const results = get_results(command);
    if (results == null)
      resolve();

    if (is(results, Error))
      reject(Errors.NoResult);

    if (is(results.returned, Error))
      reject(new AfterEffectsError(results.returned.message));
    else
      resolve(results.returned);
  }));
}
763889
function({options}, succeed, skip) {
    return each(options.if_exec).call((cmd, next) => {
      this.log({
        message: `Nikita \`if_exec\`: ${cmd}`,
        level: 'DEBUG',
        module: 'nikita/misc/conditions'
      });
      return this.system.execute({
        cmd: cmd,
        relax: true,
        stderr_log: false,
        stdin_log: false,
        stdout_log: false
      }, function(err, {code}) {
        this.log({
          message: `Nikita \`if_exec\`: code is "${code}"`,
          level: 'INFO',
          module: 'nikita/misc/conditions'
        });
        if (code === 0) {
          return next();
        } else {
          return skip();
        }
      });
    }).next(succeed);
  }
274410
function execList(options) {
  const deferred = Q.defer();

  const json = options.json !== false;
  const offline = options.offline !== false;
  const cwd = options.cwd || process.cwd();
  const config = {json, offline, cwd};

  bower.commands.list(undefined, config)
      .on('end', (conf) => {
        deferred.resolve(flatten(conf));
      })
      .on('error', (error) => {
        deferred.reject(error);
      });

  return deferred.promise;
}
849985
function Output(options) {
  options = options || {};
  this.command = options.command || '';
  this.args = options.args || {};
  this.typed = options.typed || '';
  this.canonical = options.canonical || '';
  this.hidden = options.hidden === true ? true : false;

  this.type = undefined;
  this.data = undefined;
  this.completed = false;
  this.error = false;
  this.start = new Date();

  this.promise = new Promise(function(resolve, reject) {
    this._resolve = resolve;
  }.bind(this));
}
106739
function create(options) {
  console.log('Creating app: ', options.name);

  if (!options.status)
    options.status = (code, msg) => {
      console.log(msg);
    };
  if (!options.type) options.type = 'rekit-react';

  const prjDir = path.join(options.location || process.cwd(), options.name);
  return new Promise(async (resolve, reject) => {
    try {
      if (fs.existsSync(prjDir)) {
        reject('FOLDER_EXISTS');
        return;
      }
      fs.mkdirSync(prjDir);
      let gitRepo;
      if (options.source) {
        if (/^https?:/.test(options.source)) {
          // It's a git repo
          gitRepo = options.source;
        } else {
          // It's a local folder
          const srcDir = path.isAbsolute(options.source)
            ? options.source
            : path.join(process.cwd(), options.source);
          options.status('CREATE_APP_COPY_FILES', `Copy files from ${srcDir}...`);
          await fs.copy(srcDir, prjDir, {
            filter: src => !/\/(\.git|node_modules\/|node_modules$)/.test(src) || path.basename(src) === '.gitignore',
          });
        }
      } else if (options.type) {
        // Get gitRepo
        options.status(
          'QUERY_APP_TYPES_GIT_REPO',
          `Looking for the git repo for app type ${options.type}...`,
        );
        const appTypes = await getAppTypes();
        const appType = _.find(appTypes, { id: options.type });
        if (!appType) reject('APP_TYPE_NOT_SUPPORTED');
        gitRepo = appType.repo;
      } else {
        await fs.remove(prjDir);
        reject('NO_SOURCE_OR_APP_TYPE');
      }

      if (gitRepo) {
        options.status('CLONE_PROJECT', `Downloading project from ${gitRepo}...`);
        await cloneRepo(gitRepo, prjDir);
      }

      postCreate(prjDir, options);
      options.status('CREATION_SUCCESS', '😃App creation success.');
      resolve();
    } catch (err) {
      console.log('Failed to create project.');
      fs.removeSync(prjDir);
      reject(err);
    }
  });
}
446488
function doit(originalArgs, originalSettings, jqOptions, bjOptions) {
    var xhr;
    var p = new Promise(function resolver(resolve, reject) {
      xhr = bluetry.perform.call(this, originalSettings, jqOptions, bjOptions);
      function succeded(data, textStatus, jqXHR) {
        resolve(bjOptions.verboseResults ? [data, textStatus, jqXHR] : data);
      }

      function failed(jqXHR, textStatus, errorThrown) {
        var error = makeError(
          jqXHR, textStatus, errorThrown,
          bjOptions.verboseExceptions ? originalArgs : null);

        if (!isNetworkIssue(error)) {
          // As mentioned earlier, errors that are not due to the network cause
          // an immediate rejection: no diagnosis.
          reject(error);
        }
        else {
          // Move to perhaps diagnosing what could be the problem.
          var diagnose = bjOptions.diagnose;
          if (!diagnose || !diagnose.on) {
            // The user did not request diagnosis: fail now.
            reject(error);
          }
          else {
            // Otherwise, we perform the requested diagnosis.  We cannot just
            // call ``reject`` with the return value of ``diagnoseIt``, as the
            // rejection value would be a promise and not an error. (``resolve``
            // assimilates promises, ``reject`` does not).
            resolve(diagnoseIt(error, diagnose));
          }
        }
      }

      xhr.fail(failed).done(succeded);
    });

    return { xhr: xhr, promise: p };
  }
479025
function spawnExt(command, args, options, ignoreClose = false) {
  let proc;
  const promise = new Promise((resolve, reject) => {
    let descr = command + ' ' + args.join(' ');
    console.log('running: ' + descr);
    try {
      proc = xSpawn.spawn(command, args, options);
    } catch (e) {
      console.log(e);
      reject(e);
      return { proc: null, promise };
    }
    proc.stdout.on('data', function (data) {
      process.stdout.write(data.toString());
    });
    proc.stderr.on('data', function (data) {
      process.stdout.write(data.toString());
    });
    proc.on('close', function (returnCode) {
      console.log(`completed: ${descr} \n`);
      // Many tasks (e.g., tsc) complete but are actually errors;
      // Confirm return code is zero.
      returnCode === 0 || ignoreClose ? resolve(0) : reject(returnCode);
    });
    proc.on('error', function (data) {
      console.log(`completed with error: ${descr} \n`);
      console.log(data.toString());
      reject(data);
    });
  });
  return { proc, promise };
}
923044
def _install_eslint(self, bootstrap_dir):
    
    with pushd(bootstrap_dir):
      result, install_command = self.install_module(
        package_manager=self.node_distribution.get_package_manager(package_manager=PACKAGE_MANAGER_YARNPKG),
        workunit_name=self.INSTALL_JAVASCRIPTSTYLE_TARGET_NAME,
        workunit_labels=[WorkUnitLabel.PREP])
      if result != 0:
        raise TaskError('Failed to install ESLint\n'
                        '\t{} failed with exit code {}'.format(install_command, result))

    self.context.log.debug('Successfully installed ESLint to {}'.format(bootstrap_dir))
    return bootstrap_dir
608961
function renderSync (options) {
  options = new JsdocOptions(options)
  const RenderSync = require('./lib/render-sync')
  const command = new RenderSync(options)
  return command.execute()
}
519951
function({options}, succeed, skip) {
    var ok;
    if (!Array.isArray(options.if)) {
      options.if = [options.if];
    }
    ok = true;
    return each(options.if).call((si, next) => {
      var err, type;
      if (!ok) {
        return next();
      }
      type = typeof si;
      if (si === null || type === 'undefined') {
        ok = false;
        return next();
      } else if (type === 'boolean' || type === 'number') {
        if (!si) {
          ok = false;
        }
        return next();
      } else if (type === 'function') {
        if (si.length < 2) {
          try {
            if (!si.call(this, {
              options: options
            })) {
              ok = false;
            }
            return next();
          } catch (error) {
            err = error;
            return next(err);
          }
        } else if (si.length === 2) {
          try {
            return si.call(this, {
              options: options
            }, (err, is_ok) => {
              if (err) {
                return next(err);
              }
              if (!is_ok) {
                ok = false;
              }
              return next();
            });
          } catch (error) {
            err = error;
            return next(err);
          }
        } else {
          return next(Error(`Invalid argument length, expecting 2 or less, got ${si.length}`));
        }
      } else if (type === 'string' || (type === 'object' && Buffer.isBuffer(si))) {
        si = template(si.toString(), {
          options: options
        });
        if (si.length === 0) {
          ok = false;
        }
        return next();
      } else {
        return next(Error(`Invalid condition "if": ${JSON.stringify(si)}`));
      }
    }).next(function(err) {
      if (err || !ok) {
        return skip(err);
      } else {
        return succeed();
      }
    });
  }
331452
function execLinter(bin, args, execaOptions, pathsToLint) {
  const binArgs = args.concat(pathsToLint)

  debug('bin:', bin)
  debug('args: %O', binArgs)
  debug('opts: %o', execaOptions)

  return execa(bin, binArgs, { ...execaOptions })
}
215685
function executePromiseTask (promise, fn) {
    // Promise Resolution Procedure:
    // https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
    try {
        fn(value => {
            if (promise._state !== null) return; // Already settled
            if (value === promise) throw new TypeError('A promise cannot be resolved with itself.');
            var shouldExecuteTick = promise._lib && beginMicroTickScope();
            if (value && typeof value.then === 'function') {
                executePromiseTask(promise, (resolve, reject) => {
                    value instanceof Promise ?
                        value._then(resolve, reject) :
                        value.then(resolve, reject);
                });
            } else {
                promise._state = true;
                promise._value = value;
                propagateAllListeners(promise);
            }
            if (shouldExecuteTick) endMicroTickScope();
        }, handleRejection.bind(null, promise)); // If Function.bind is not supported. Exception is handled in catch below
    } catch (ex) {
        handleRejection(promise, ex);
    }
}
42650
function validateOptions (options) {
  if (typeof options.apiKey !== 'string') {
    throw new Error('You must provide a valid API key to upload sourcemaps to Bugsnag.')
  }
  if (typeof options.sourceMap !== 'string') {
    throw new Error('You must provide a path to the source map you want to upload.')
  }
  if (options.addWildcardPrefix && !options.stripProjectRoot) {
    options.stripProjectRoot = true
  }
  if (options.uploadSources && !options.projectRoot) {
    throw new Error('You must provide a project root when uploading sources. ' +
      'The project root is used to generate relative paths to the sources.')
  }
  if (options.stripProjectRoot && !options.projectRoot) {
    throw new Error('You must provide a project root when stripping the root ' +
      'path from the source map.')
  }
  if (options.projectRoot && !path.isAbsolute(options.projectRoot)) {
    options.projectRoot = path.resolve(options.projectRoot)
  }
  return options
}
1039217
function Output(options) {
  options = options || {};
  this.command = options.command || '';
  this.args = options.args || {};
  this.typed = options.typed || '';
  this.canonical = options.canonical || '';
  this.hidden = options.hidden === true ? true : false;

  this.data = undefined;
  this.completed = false;
  this.error = false;
  this.start = new Date();

  this.deferred = Promise.defer();
  this.then = this.deferred.promise.then;

  this.onClose = util.createEvent('Output.onClose');
  this.onChange = util.createEvent('Output.onChange');
}
562654
function execute(method, params) {
  var output = !params ? [] : params;

  if (method == "getStandardEvents") {
    return new Promise(function promise(resolve, reject) {
      resolve(standardEvent);  
    });
  }

  return new Promise(function promise(resolve, reject) {
    exec(
      function success(res) {
        resolve(res);
      },
      function failure(err) {
        reject(err);
      },
      API_CLASS,
      method,
      output
    );
  });
}
1291227
def run(args)
      options = SCSSLint::Options.new.parse(args)
      act_on_options(options)
    rescue StandardError => e
      handle_runtime_exception(e, options)
    end