4 // resolve allow us to load the locally installed esformatter instead of using
6 var requireResolve = require('resolve').sync;
7 var path = require('path');
8 var dirname = path.dirname;
9 var pathResolve = path.resolve;
11 var argv = process.argv.slice(2);
13 // if user sets a config file we use that as the base directory to start the
14 // search because we assume that some settings aren't backwards compatible
15 // otherwise we just use the process.cwd()
16 var opts = require('../lib/cli.js').parse(argv);
17 var basedir = opts.config ?
18 pathResolve(dirname(opts.config)) :
23 cliPath = requireResolve('esformatter', {
26 cliPath = pathResolve(dirname(cliPath), './cli.js');
28 // fallback to this version instead
29 cliPath = '../lib/cli.js';
32 var cli = require(cliPath);
33 // until v0.5 the cli module only exposed a single `parse` method, after v0.6
34 // we expose 2 methods to allow processing the data before executing the
35 // command (all the logic above)
37 cli.run(cli.parse(argv));