Skip to content

Commit 65718bc

Browse files
committed
Add worker.remove()
1 parent d799260 commit 65718bc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/createWorker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ module.exports = (_options = {}) => {
8585
}))
8686
);
8787

88+
const remove = (path, jobId) => (
89+
startJob(createJob({
90+
id: jobId, action: 'remove', payload: { path },
91+
}))
92+
);
93+
8894
const run = (args, jobId) => (
8995
startJob(createJob({
9096
id: jobId, action: 'run', payload: { args },
@@ -132,6 +138,7 @@ module.exports = (_options = {}) => {
132138
write,
133139
transcode,
134140
read,
141+
remove,
135142
run,
136143
terminate,
137144
};

src/worker-script/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ const read = ({
8080
res.resolve(Module.FS.readFile(path));
8181
};
8282

83+
const remove = ({
84+
payload: {
85+
path,
86+
},
87+
}, res) => {
88+
Module.FS.unlink(path);
89+
res.resolve({ message: `Delete ${path}` });
90+
};
91+
8392
const run = ({
8493
payload: {
8594
args,
@@ -108,6 +117,7 @@ exports.dispatchHandlers = (packet, send) => {
108117
write,
109118
transcode,
110119
read,
120+
remove,
111121
run,
112122
})[packet.action](packet, res);
113123
} catch (err) {

0 commit comments

Comments
 (0)