@pfmcodes/n
Version:
n is a module node which compiles and does all the heavy work for you
29 lines (27 loc) • 913 B
text/typescript
const { nconfig, configExists, ask, rl } = require("../global");
const { init } = require("./init");
import * as fs from 'fs';
async function add() {
if (configExists) {
const newScript = await ask("what should it be named?: ")
const newScriptValue = await ask("what should it do?(commands only): ")
// Use the script name as the file path directly
nconfig.custom[newScript] = newScriptValue;
fs.writeFileSync("n.config.json", JSON.stringify(nconfig, null, 2));
process.exit()
}
else {
console.log("Looks like n.config.json doesn't exist")
const yorn = await ask("Would you like to create it?(y/n): ")
if (yorn == "y") {
init()
process.exit()
}
else {
rl.close()
process.exit()
}
}
}
module.exports = { add }
export { add }