-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutil.js
More file actions
22 lines (18 loc) · 697 Bytes
/
Copy pathutil.js
File metadata and controls
22 lines (18 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const path = require('path');
const fs = require('fs');
const outputPath = path.resolve('./', 'output.json');
const argv = key => {
// Return true if the key exists and a value is defined
if ( process.argv.includes( `--${ key }` ) ) return true;
const value = process.argv.find( element => element.startsWith( `--${ key }=` ) );
// Return null if the key does not exist and a value is not defined
if ( !value ) return null;
return value.replace( `--${ key }=` , '' );
}
const printLog = str =>{
if (fs.existsSync(outputPath)) {
fs.unlinkSync(outputPath);
}
fs.writeFile(outputPath, str, null, () => {});
}
module.exports = {argv, printLog}