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) {
62
62
let tokens ;
63
63
let config ;
64
64
let opt ;
65
+ let noclobber ;
65
66
66
67
function getArg ( ) {
67
68
let arg = argv . shift ( ) ;
@@ -114,6 +115,10 @@ export async function main(nodeProcess) {
114
115
case '--config' :
115
116
config = argv . shift ( ) ;
116
117
break ;
118
+ case '-n' :
119
+ case '--no-clobber' :
120
+ noclobber = true ;
121
+ break ;
117
122
case '-h' :
118
123
case '--help' :
119
124
return await help ( ) ;
@@ -216,6 +221,10 @@ export async function main(nodeProcess) {
216
221
: await marked . parse ( data , options ) ;
217
222
218
223
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
+ }
219
228
return await writeFile ( output , html ) ;
220
229
}
221
230
Original file line number Diff line number Diff line change 2
2
3
3
## SYNOPSIS
4
4
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]
6
6
7
7
## DESCRIPTION
8
8
@@ -45,6 +45,9 @@ Specify config file to use instead of the default `~/.marked.json` or `~/.marked
45
45
* -t, --tokens
46
46
Output a token list instead of html.
47
47
48
+ * -n, --no-clobber
49
+ Do not overwrite ` output ` if it exists.
50
+
48
51
* --pedantic
49
52
Conform to obscure parts of markdown.pl as much as possible.
50
53
Don't fix original markdown bugs.
You can’t perform that action at this time.
0 commit comments