|
@@ -62,6 +62,7 @@ export async function main(nodeProcess) {
|
|
let tokens;
|
|
let tokens;
|
|
let config;
|
|
let config;
|
|
let opt;
|
|
let opt;
|
|
|
|
+ let noclobber;
|
|
|
|
|
|
function getArg() {
|
|
function getArg() {
|
|
let arg = argv.shift();
|
|
let arg = argv.shift();
|
|
@@ -114,6 +115,10 @@ export async function main(nodeProcess) {
|
|
case '--config':
|
|
case '--config':
|
|
config = argv.shift();
|
|
config = argv.shift();
|
|
break;
|
|
break;
|
|
|
|
+ case '-n':
|
|
|
|
+ case '--no-clobber':
|
|
|
|
+ noclobber = true;
|
|
|
|
+ break;
|
|
case '-h':
|
|
case '-h':
|
|
case '--help':
|
|
case '--help':
|
|
return await help();
|
|
return await help();
|
|
@@ -216,6 +221,10 @@ export async function main(nodeProcess) {
|
|
: await marked.parse(data, options);
|
|
: await marked.parse(data, options);
|
|
|
|
|
|
if (output) {
|
|
if (output) {
|
|
|
|
+ if (noclobber && await fileExists(output)) {
|
|
|
|
+ nodeProcess.stderr.write('marked: output file \'' + output + '\' already exists, disable the \'-n\' / \'--no-clobber\' flag to overwrite\n');
|
|
|
|
+ nodeProcess.exit(1);
|
|
|
|
+ }
|
|
return await writeFile(output, html);
|
|
return await writeFile(output, html);
|
|
}
|
|
}
|
|
|
|
|