Add worker.remove()

This commit is contained in:
jeromewu 2019-11-06 12:23:29 +00:00
parent fbdc691184
commit dbcb56b55c
2 changed files with 17 additions and 0 deletions

View File

@ -85,6 +85,12 @@ module.exports = (_options = {}) => {
}))
);
const remove = (path, jobId) => (
startJob(createJob({
id: jobId, action: 'remove', payload: { path },
}))
);
const run = (args, jobId) => (
startJob(createJob({
id: jobId, action: 'run', payload: { args },
@ -132,6 +138,7 @@ module.exports = (_options = {}) => {
write,
transcode,
read,
remove,
run,
terminate,
};

View File

@ -80,6 +80,15 @@ const read = ({
res.resolve(Module.FS.readFile(path));
};
const remove = ({
payload: {
path,
},
}, res) => {
Module.FS.unlink(path);
res.resolve({ message: `Delete ${path}` });
};
const run = ({
payload: {
args,
@ -108,6 +117,7 @@ exports.dispatchHandlers = (packet, send) => {
write,
transcode,
read,
remove,
run,
})[packet.action](packet, res);
} catch (err) {