Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ========================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/cat.js
// ========================================================================
var output_file = function(file: string) {
cli.withInput(file, function (line, sep, eof) {
if (!eof) {
cli.output(line + sep);
} else if (cli.args.length) {
output_file(cli.args.shift());
}
});
};
if (cli.args.length) {
output_file(cli.args.shift());
}
// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/command.js
// ============================================================================
cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);
console.log('Command is: ' + cli.command);
// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/echo.js
// ============================================================================
const config = require('./config/config.json');
const cli = require('cli');
var shared = require('./shared');
// parse args
let args = cli.args;
if(args.length > 0){
args = args[0];
}
// Build docs
if(args === 'build'){
shared.build(function(){
console.log("[INFO] Successfully built");
process.exit(0);
});
}else if(args === 'serve'){
require("./server")
}else{
console.log("[ERROR] No option selected. Valid options are: build, serve");
}
// This is a hack. exports.run is both sync and async function
// because I needed stdin support (and cli.withStdin is async)
// and was too lazy to change tests.
function done(passed) {
/*jshint eqnull:true */
if (passed == null)
return;
exports.exit(passed ? 0 : 2);
}
done(exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores({exclude: options.exclude, excludePath: options["exclude-path"]}),
extensions: options["extra-ext"],
verbose: options.verbose,
extract: options.extract,
filename: options.filename,
useStdin: {"-": true, "/dev/stdin": true}[args[args.length - 1]]
}, done));
}
};
// This is a hack. exports.run is both sync and async function
// because I needed stdin support (and cli.withStdin is async)
// and was too lazy to change tests.
function done(passed) {
/*jshint eqnull:true */
if (passed == null)
return;
exports.exit(passed ? 0 : 2);
}
done(exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores({ exclude: options.exclude, excludePath: options["exclude-path"] }),
extensions: options["extra-ext"],
verbose: options.verbose,
extract: options.extract,
filename: options.filename,
prereq: options.prereq,
useStdin: { "-": true, "/dev/stdin": true }[args[args.length - 1]]
}, done));
}
};
cli
.enable('version')
.setApp(pkg.name, pkg.version)
.setUsage(cli.app + ' [OPTIONS]
// This is a hack. exports.run is both sync and async function
// because I needed stdin support (and cli.withStdin is async)
// and was too lazy to change tests.
function done(passed) {
/*jshint eqnull:true */
if (passed == null)
return;
exports.exit(passed ? 0 : 2);
}
done(exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores({ exclude: options.exclude, excludePath: options["exclude-path"] }),
extensions: options["extra-ext"],
verbose: options.verbose,
extract: options.extract,
filename: options.filename,
prereq: options.prereq,
useStdin: { "-": true, "/dev/stdin": true }[args[args.length - 1]]
}, done));
}
};
var fs = require('fs'),
path = require('path');
try {
require(path.join(process.cwd(), 'express.js')).init(dev_server.app);
util.puts("Loaded express.js");
} catch(e) {}
dev_server.init();
dev_server.app.listen(port, host);
util.puts("Server at http://" + (host || "127.0.0.1") + ":" + port.toString() + "/");
} else if (cli.command == 'build') {
var static_require = require('./static_require');
var file = cli.args[0];
var options = { filePath: cli.args[0], squeeze: cli.options.squeeze };
var code = static_require.require(options);
console.log(code);
}
var fs = require('fs');
var _ = require('lodash');
var async = require('async');
var moment = require('moment');
var cli = require('cli');
cli.parse();
var owner = 'secui';
if(!cli.args[0]) {
console.log('node pushIssues.js repoName');
return;
}
var repo = cli.args[0];
var dest = {
options: {
url: "https://c201sa26.jci.com/api/v3"
},
token: "af58f10c5bef7dbdcf812ccb2c848b2dcef5d383",
repo: owner + '/' + repo,
ca: require('fs').readFileSync('/Users/mgwelch/DropBox/JCI Root CA.pem')
};
var destApiUrl = (dest.options && dest.options.url) || "https://api.github.com";
var destRepoUrl = destApiUrl + '/repos/' + dest.repo;
var destHeaders = {
'Authorization': 'token ' + dest.token,
'user-agent': 'node.js'
};
});
}
function compile(data, name) {
var compiled;
try {
compiled = compiler.compile(parser.parse(data), name);
} catch (e) {
return cli.fatal('[' + name + '] ' + e);
}
return compiled;
}
let paths = glob(cli.args);
handle();