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

View File

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