UNPKG

hytescript.js

Version:

A package for programming anything you want with ease.

29 lines (27 loc) 779 B
const fs = require('fs') module.exports = { description: 'Writes a file, replaces file content if file exists.', usage: 'path | content?', parameters: [ { name: 'Path', description: 'The file path.', optional: 'false', defaultValue: 'none' }, { name: 'Content', description: 'The file content.', optional: 'false', defaultValue: 'none' } ], run: async (d, path, content) => { if (path == undefined) return new d.error("required", d, 'path') try { fs.writeFileSync(path, content) } catch (e) { return new d.error("custom", d, e.message) } } }