File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ export async function main(nodeProcess) {
6262 let tokens ;
6363 let config ;
6464 let opt ;
65+ let noclobber ;
6566
6667 function getArg ( ) {
6768 let arg = argv . shift ( ) ;
@@ -114,6 +115,10 @@ export async function main(nodeProcess) {
114115 case '--config' :
115116 config = argv . shift ( ) ;
116117 break ;
118+ case '-n' :
119+ case '--no-clobber' :
120+ noclobber = true ;
121+ break ;
117122 case '-h' :
118123 case '--help' :
119124 return await help ( ) ;
@@ -216,6 +221,10 @@ export async function main(nodeProcess) {
216221 : await marked . parse ( data , options ) ;
217222
218223 if ( output ) {
224+ if ( noclobber && await fileExists ( output ) ) {
225+ nodeProcess . stderr . write ( 'marked: output file \'' + output + '\' already exists, disable the \'-n\' / \'--no-clobber\' flag to overwrite\n' ) ;
226+ nodeProcess . exit ( 1 ) ;
227+ }
219228 return await writeFile ( output , html ) ;
220229 }
221230
Original file line number Diff line number Diff line change 22
33## SYNOPSIS
44
5- ` marked ` [ ` -o ` <output file >] [ ` -i ` <input file >] [ ` -s ` <markdown string >] [ ` -c ` <config file >] [ ` --help ` ] [ ` --version ` ] [ ` --tokens ` ] [ ` --pedantic ` ] [ ` --gfm ` ] [ ` --breaks ` ] [ ` --no-etc... ` ] [ ` --silent ` ] [ filename]
5+ ` marked ` [ ` -o ` <output file >] [ ` -i ` <input file >] [ ` -s ` <markdown string >] [ ` -c ` <config file >] [ ` --help ` ] [ ` --version ` ] [ ` --tokens ` ] [ ` --no-clobber ` ] [ ` -- pedantic` ] [ ` --gfm ` ] [ ` --breaks ` ] [ ` --no-etc... ` ] [ ` --silent ` ] [ filename]
66
77## DESCRIPTION
88
@@ -45,6 +45,9 @@ Specify config file to use instead of the default `~/.marked.json` or `~/.marked
4545* -t, --tokens
4646Output a token list instead of html.
4747
48+ * -n, --no-clobber
49+ Do not overwrite ` output ` if it exists.
50+
4851* --pedantic
4952Conform to obscure parts of markdown.pl as much as possible.
5053Don't fix original markdown bugs.
You can’t perform that action at this time.
0 commit comments