Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Reporter that displays additional JSHint data
case options["show-non-errors"]:
options.reporter = "../reporters/non_error.js";
break;
// Custom reporter
case options.reporter !== undefined:
options.reporter = path.resolve(process.cwd(), options.reporter);
}
var reporter;
if (options.reporter) {
reporter = loadReporter(options.reporter);
if (reporter === null) {
cli.error("Can't load reporter file: " + options.reporter);
process.exit(1);
}
}
var passed = exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores(),
extensions: options["extra-ext"],
verbose: options.verbose
});
// Patch as per https://github.com/visionmedia/mocha/issues/333
// fixes issues with piped output on Windows.
// Root issue is here https://github.com/joyent/node/issues/3584
function packer(options) {
if(!options.source) {
cli.error("No source parameter specified");
return;
}
if(!fs.existsSync(options.source)) {
cli.error("Source directory \"" + options.source + "\" doesn't exist");
return;
}
if(!options.output) {
cli.error("No output parameter specified");
return;
}
if(!fs.existsSync(options.output)) {
cli.error("Output directory \"" + options.output + "\" doesn't exist");
return;
}
const source = addTrailingSlash(options.source);
const output = addTrailingSlash(options.output);
const name = options.name || "pack";
debug = options.debug || false;
options.mimeTypes = options.mimeTypes || [];
printDebug("Source: " + source);
printDebug("Output: " + output);
printDebug("Name: " + name);
const files = listFiles(source);
// printDebug(files);
pack(files, source, output, name, options.mimeTypes);
function loadConfig(fp) {
if (!fp) {
return {};
}
if (!shjs.test("-e", fp)) {
cli.error("Can't find config file: " + fp);
process.exit(1);
}
try {
return JSON.parse(removeComments(shjs.cat(fp)));
} catch (err) {
cli.error("Can't parse config file: " + fp);
process.exit(1);
}
}
function collect(fp, files, ignores, ext) {
if (ignores && isIgnored(fp, ignores)) {
return;
}
if (!shjs.test("-e", fp)) {
cli.error("Can't open " + fp);
return;
}
if (shjs.test("-d", fp)) {
shjs.ls(fp).forEach(function (item) {
var itempath = path.join(fp, item);
if (shjs.test("-d", itempath) || item.match(ext)) {
collect(itempath, files, ignores, ext);
}
});
return;
}
files.push(fp);
}
function collect(fp, files, ignores, ext) {
if (ignores && isIgnored(fp, ignores)) {
return;
}
if (!shjs.test("-e", fp)) {
cli.error("Can't open " + fp);
return;
}
if (shjs.test("-d", fp)) {
shjs.ls(fp).forEach(function (item) {
var itempath = path.join(fp, item);
if (shjs.test("-d", itempath) || item.match(ext)) {
collect(itempath, files, ignores, ext);
}
});
return;
}
files.push(fp);
}
cli.error("Can't find config file: " + fp);
exports.exit(1);
}
try {
var config = JSON.parse(removeComments(shjs.cat(fp)));
config.dirname = path.dirname(fp);
if (config['extends']) {
_.defaults(config, exports.loadConfig(path.resolve(config.dirname, config['extends'])));
delete config['extends'];
}
return config;
} catch (err) {
cli.error("Can't parse config file: " + fp);
exports.exit(1);
}
},
},function(err,html) {
if (err) return cli.error(err);
fs.writeFile('./_site'+path,html,function(err) {
if (err) cli.error(err);
});
});
helpers.error = function(message, options) {
if (options.quiet || options.q) {
return;
}
cli.error(message);
};