Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config.from = input
config.to = output
if (output) {
mkdirp.sync(path.dirname(output))
}
// init & adjust watcher with postcss-import dependencies
let watcher
if (config.watch) {
if (!input || !output) {
console.error(
color.red("--watch option need both <input> & <output> files to work")
)
exit(3)
}
watcher = require("chokidar").watch(input, {ignoreInitial: true})
if (verbose) {
log(color.cyan("Watching"), input)
}
// https://github.com/paulmillr/chokidar/issues/288
// ready event might not be triggered at all
// watcher.on("ready", function() {
// if (verbose) {
// log(color.cyan("Watcher ready"), input)
// }
// })
</output>
config.sourcemap = program.sourcemap
}
if ("compress" in program) {
config.compress = program.compress
}
if ("watch" in program) {
config.watch = program.watch
}
const input = program.args[0] ? path.resolve(program.args[0]) : null
const output = program.args[1] ? path.resolve(program.args[1]) : null
const verbose = program.verbose
if (input && !fs.existsSync(input)) {
console.error(color.red("Unable to read file"), input)
exit(1)
}
config.from = input
config.to = output
if (output) {
mkdirp.sync(path.dirname(output))
}
// init & adjust watcher with postcss-import dependencies
let watcher
if (config.watch) {
if (!input || !output) {
console.error(
color.red("--watch option need both <input> & <output> files to work")
)</output>
}
for (const key of Object.keys(options)) {
cmd.option(key, options[key]);
}
try {
const args = cmd.parse(argv);
const result = await template.generate(args);
await writeFiles(args.cwd, result.files);
signale.success("%d files are generated", result.files.length);
} catch (err) {
// tslint:disable-next-line:no-console
console.error(err);
exit(1);
throw err;
}
}
function errorTrap (error) {
process.stderr.write('\n' + error.stack + '\n')
exit(1)
}
const proc = exec( command, ( error, stdout, stderr ) => {
if ( error ) {
console.error( `exec error: ${ error }` );
return;
}
process.stdout.write( stdout );
process.stderr.write( stderr );
exit(proc.code);
});
} else {
}
}
catch (e) {
console.error()
console.error(color.bold("cssnext encounters an error:"))
console.error()
console.error(color.red(e.message))
if (e.stack) {
console.error(e.stack.split("\n").slice(1).join("\n").grey)
console.error()
}
console.error("If this error looks like a bug, please report it here:")
console.error(color.grey("❯ ") + color.cyan(pkg.bugs.url))
console.error()
if (!config.watch) {
exit(2)
}
}
})
}
handleFailure = (error: Error) => {
this.start();
this.debug('Uncaught exception or unresolved promise handled');
this.stop(error);
exit(2);
};
function exitProcess(): void {
exit(0);
}
process.once('SIGINT', () => {
config.sys.destroy();
devServer && devServer.close();
exit(0);
});
}
.then(code => exit(code)),
};