diff options
Diffstat (limited to 'docker/netiquette/src/io')
-rw-r--r-- | docker/netiquette/src/io/files.mjs | 8 | ||||
-rw-r--r-- | docker/netiquette/src/io/run.mjs | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/docker/netiquette/src/io/files.mjs b/docker/netiquette/src/io/files.mjs new file mode 100644 index 0000000..c3eca1b --- /dev/null +++ b/docker/netiquette/src/io/files.mjs @@ -0,0 +1,8 @@ +'use strict' + +import fs from 'fs' + +export const readFile = (file, opts) => + new Promise((resolve, reject) => + fs.readFile(file, opts, (err, data) => + err ? reject(err) : resolve(data))) diff --git a/docker/netiquette/src/io/run.mjs b/docker/netiquette/src/io/run.mjs new file mode 100644 index 0000000..8774043 --- /dev/null +++ b/docker/netiquette/src/io/run.mjs @@ -0,0 +1,9 @@ +'use strict' + +import child_process from 'child_process' + +export const exec = (cmd, opts) => + new Promise((resolve, reject) => + child_process.exec(cmd, opts, (error, stdout, stderr) => + error ? reject({err: error, stdout: stdout, stderr: stderr}) : resolve({stdout: stdout, stderr: stderr}))) + |