Writing to a file from the console?

0 like 0 dislike
6 views
fs.writeFile('./public/library.js',obfuscationResult.getObfuscatedCode(),function(err){ fs.readFile('./public/library.js',"utf8",function(error,data){ fs.writeFile('./public/library.js','/*\* JavaScript Library v1.1.77\'); fs.appendFile('./public/library.js',data); }); });

Take the contents of the file, compress, store in a public directory, re-open, add in the beginning of the file lines.
Question
I have added the same line "JavaScript Library v1.1.77"
I want to enter the version manually.
But how to do to add lines to the file executed only after I enter the version number in console ?
by | 6 views

1 Answer

0 like 0 dislike
The fact that already tried a few options but they didn't work. In particular, the module read.
The recording was made before I introduced the data in the console.
That's how readline works
fs.writeFile('./public/library.js',obfuscationResult.getObfuscatedCode(),function(err){ fs.readFile('./public/library.js',"utf8",function(error,data){ var rl = readline.createInterface({ input:process.stdin, output:process.stdout }); rl.question('What do you think of Node.js? ', (answer) => { fs.writeFile('./public/library.js','/*\* JavaScript Library v'+answer); fs.appendFile('./public/library.js',data); rl.close(); }); }); });
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
5 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
33,715 users