bree-plugin-one-time 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +14 -10
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -137,16 +137,20 @@ module.exports = function oneTimePlugin(options, Bree) {
|
|
|
137
137
|
|
|
138
138
|
const originalStart = Bree.prototype.start;
|
|
139
139
|
|
|
140
|
-
Bree.prototype.start = async function () {
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
Bree.prototype.start = async function (name) {
|
|
141
|
+
// Bree calls this.start(job.name) internally for each job — only attach
|
|
142
|
+
// the cleanup listener on the initial no-arg "start everything" call to
|
|
143
|
+
// avoid infinite recursion (Bree binds this.start in the constructor).
|
|
144
|
+
if (!name) {
|
|
145
|
+
this.on('worker deleted', (workerName) => {
|
|
146
|
+
const queue = loadQueue();
|
|
147
|
+
const wasOneTime = queue.some(j => j.name === workerName);
|
|
148
|
+
if (wasOneTime) {
|
|
149
|
+
removeFromQueue(workerName);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
149
153
|
|
|
150
|
-
return originalStart.call(this);
|
|
154
|
+
return originalStart.call(this, name);
|
|
151
155
|
};
|
|
152
156
|
};
|
package/package.json
CHANGED