@pipelab/plugin-filesystem 1.0.0-beta.28 → 1.0.0-beta.31

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/dist/index.cjs CHANGED
@@ -89411,7 +89411,7 @@ const runWithLiveLogs = async (command, args, execaOptions, log, hooks, abortSig
89411
89411
  TERM: "xterm-256color",
89412
89412
  FORCE_STDERR_LOGGING: "1"
89413
89413
  },
89414
- cancelSignal: abortSignal
89414
+ cancelSignal: abortSignal ?? execaOptions.cancelSignal
89415
89415
  });
89416
89416
  hooks?.onCreated?.(subprocess);
89417
89417
  subprocess.stdout?.on("data", (data) => {
@@ -151152,16 +151152,32 @@ const zip = createAction({
151152
151152
  meta: {}
151153
151153
  });
151154
151154
  const zipRunner = createActionRunner(async ({ log, inputs, setOutput, abortSignal }) => {
151155
- abortSignal.addEventListener("abort", () => {
151156
- throw new Error("Aborted");
151157
- });
151158
- const output = (0, node_fs.createWriteStream)(inputs.output);
151155
+ const { folder, output: outputPath } = inputs;
151156
+ if (!folder) throw new Error("Missing folder");
151157
+ if (!outputPath) throw new Error("Missing output path");
151158
+ if (abortSignal.aborted) {
151159
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151160
+ abortError.name = "AbortError";
151161
+ throw abortError;
151162
+ }
151163
+ const output = (0, node_fs.createWriteStream)(outputPath);
151159
151164
  const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
151160
151165
  return new Promise((resolve, reject) => {
151166
+ const onAbort = () => {
151167
+ try {
151168
+ archive.abort();
151169
+ } catch {}
151170
+ try {
151171
+ output.destroy();
151172
+ } catch {}
151173
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151174
+ abortError.name = "AbortError";
151175
+ reject(abortError);
151176
+ };
151177
+ abortSignal.addEventListener("abort", onAbort);
151161
151178
  output.on("close", function() {
151162
- console.log(archive.pointer() + " total bytes");
151163
- console.log("archiver has been finalized and the output file descriptor has closed.");
151164
- setOutput("path", inputs.output);
151179
+ abortSignal.removeEventListener("abort", onAbort);
151180
+ setOutput("path", outputPath);
151165
151181
  resolve();
151166
151182
  });
151167
151183
  output.on("end", function() {
@@ -151169,9 +151185,13 @@ const zipRunner = createActionRunner(async ({ log, inputs, setOutput, abortSigna
151169
151185
  });
151170
151186
  archive.on("warning", function(err) {
151171
151187
  if (err.code === "ENOENT") console.log("Archiver warning: ENOENT");
151172
- else reject(err);
151188
+ else {
151189
+ abortSignal.removeEventListener("abort", onAbort);
151190
+ reject(err);
151191
+ }
151173
151192
  });
151174
151193
  archive.on("error", function(err) {
151194
+ abortSignal.removeEventListener("abort", onAbort);
151175
151195
  reject(err);
151176
151196
  });
151177
151197
  archive.on("entry", function(data) {
@@ -151181,7 +151201,7 @@ const zipRunner = createActionRunner(async ({ log, inputs, setOutput, abortSigna
151181
151201
  log("finish");
151182
151202
  });
151183
151203
  archive.pipe(output);
151184
- archive.directory(inputs.folder, false);
151204
+ archive.directory(folder, false);
151185
151205
  archive.finalize();
151186
151206
  });
151187
151207
  });
@@ -151207,18 +151227,31 @@ const zipV2 = createAction({
151207
151227
  meta: {}
151208
151228
  });
151209
151229
  const zipV2Runner = createActionRunner(async ({ log, inputs, setOutput, abortSignal, paths }) => {
151210
- abortSignal.addEventListener("abort", () => {
151211
- throw new Error("Aborted");
151212
- });
151230
+ if (abortSignal.aborted) {
151231
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151232
+ abortError.name = "AbortError";
151233
+ throw abortError;
151234
+ }
151213
151235
  const outputDir = paths.cache;
151214
151236
  const outputFile = (0, node_path.join)(outputDir, "output.zip");
151215
151237
  console.log("outputFile", outputFile);
151216
151238
  const output = (0, node_fs.createWriteStream)(outputFile);
151217
151239
  const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
151218
151240
  return new Promise((resolve, reject) => {
151241
+ const onAbort = () => {
151242
+ try {
151243
+ archive.abort();
151244
+ } catch {}
151245
+ try {
151246
+ output.destroy();
151247
+ } catch {}
151248
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151249
+ abortError.name = "AbortError";
151250
+ reject(abortError);
151251
+ };
151252
+ abortSignal.addEventListener("abort", onAbort);
151219
151253
  output.on("close", function() {
151220
- console.log(archive.pointer() + " total bytes");
151221
- console.log("archiver has been finalized and the output file descriptor has closed.");
151254
+ abortSignal.removeEventListener("abort", onAbort);
151222
151255
  setOutput("path", outputFile);
151223
151256
  resolve();
151224
151257
  });
@@ -151227,9 +151260,13 @@ const zipV2Runner = createActionRunner(async ({ log, inputs, setOutput, abortSig
151227
151260
  });
151228
151261
  archive.on("warning", function(err) {
151229
151262
  if (err.code === "ENOENT") console.log("Archiver warning: ENOENT");
151230
- else reject(err);
151263
+ else {
151264
+ abortSignal.removeEventListener("abort", onAbort);
151265
+ reject(err);
151266
+ }
151231
151267
  });
151232
151268
  archive.on("error", function(err) {
151269
+ abortSignal.removeEventListener("abort", onAbort);
151233
151270
  reject(err);
151234
151271
  });
151235
151272
  archive.on("entry", function(data) {
@@ -152106,20 +152143,34 @@ const unzip = createAction({
152106
152143
  icon: "",
152107
152144
  meta: {}
152108
152145
  });
152109
- const unzipRunner = createActionRunner(async ({ log, inputs, setOutput, cwd }) => {
152110
- console.log("inputs", inputs);
152111
- console.log("inputs.file", inputs.file);
152146
+ const unzipRunner = createActionRunner(async ({ log, inputs, setOutput, cwd, abortSignal }) => {
152147
+ if (abortSignal.aborted) {
152148
+ const abortError = /* @__PURE__ */ new Error("Aborted");
152149
+ abortError.name = "AbortError";
152150
+ throw abortError;
152151
+ }
152112
152152
  const file = inputs.file;
152113
- console.log("file", file);
152114
152153
  const output = (0, node_path.join)(cwd);
152115
- console.log("file", file);
152116
- console.log("output", output);
152117
152154
  log("Unzip file", inputs.file, "to", output);
152118
152155
  const zip = new import_node_stream_zip.default.async({ file });
152119
- const bytes = await zip.extract(null, output);
152120
- await zip.close();
152121
- console.log("bytes", bytes);
152122
- setOutput("output", output);
152156
+ const onAbort = () => {
152157
+ zip.close().catch(() => {});
152158
+ };
152159
+ abortSignal.addEventListener("abort", onAbort);
152160
+ try {
152161
+ await zip.extract(null, output);
152162
+ await zip.close();
152163
+ setOutput("output", output);
152164
+ } catch (e) {
152165
+ if (abortSignal.aborted) {
152166
+ const abortError = /* @__PURE__ */ new Error("Aborted");
152167
+ abortError.name = "AbortError";
152168
+ throw abortError;
152169
+ }
152170
+ throw e;
152171
+ } finally {
152172
+ abortSignal.removeEventListener("abort", onAbort);
152173
+ }
152123
152174
  });
152124
152175
  const copy = createAction({
152125
152176
  id: "fs:copy",
@@ -152189,18 +152240,10 @@ const copy = createAction({
152189
152240
  icon: "",
152190
152241
  meta: {}
152191
152242
  });
152192
- const copyRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152243
+ const copyRunner = createActionRunner(async ({ log, inputs, setOutput, abortSignal }) => {
152193
152244
  log("");
152194
152245
  const from = inputs.from;
152195
152246
  let to = inputs.to;
152196
- let fromIsAFile = false;
152197
- try {
152198
- if ((await (0, node_fs_promises.stat)(from)).isFile()) fromIsAFile = true;
152199
- } catch (e) {
152200
- log("Error getting file stats", e);
152201
- throw e;
152202
- }
152203
- const fromFileName = fromIsAFile ? (0, node_path.basename)(from) : "";
152204
152247
  if (!from) {
152205
152248
  log("From", from);
152206
152249
  throw new Error("Missing source");
@@ -152209,6 +152252,14 @@ const copyRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152209
152252
  log("To", to);
152210
152253
  throw new Error("Missing destination");
152211
152254
  }
152255
+ let fromIsAFile = false;
152256
+ try {
152257
+ if ((await (0, node_fs_promises.stat)(from)).isFile()) fromIsAFile = true;
152258
+ } catch (e) {
152259
+ log("Error getting file stats", e);
152260
+ throw e;
152261
+ }
152262
+ const fromFileName = fromIsAFile ? (0, node_path.basename)(from) : "";
152212
152263
  if (fromIsAFile) try {
152213
152264
  if ((await (0, node_fs_promises.stat)(to)).isDirectory()) to = (0, node_path.join)(to, fromFileName);
152214
152265
  } catch (e) {}
@@ -152271,7 +152322,7 @@ const remove = createAction({
152271
152322
  icon: "",
152272
152323
  meta: {}
152273
152324
  });
152274
- const removeRunner = createActionRunner(async ({ log, inputs }) => {
152325
+ const removeRunner = createActionRunner(async ({ log, inputs, abortSignal }) => {
152275
152326
  log("");
152276
152327
  const from = inputs.from;
152277
152328
  log("Removing", from, inputs.recursive);
@@ -152388,10 +152439,11 @@ const runRunner = createActionRunner(async ({ log, inputs, setOutput, abortSigna
152388
152439
  console.log("error", error);
152389
152440
  if (inputs.stopOnError === true) throw error;
152390
152441
  else if (error) {
152391
- setOutput("exitCode", error.exitCode === void 0 ? -1 : error.exitCode);
152392
- setOutput("stdout", error.stdout ?? "");
152393
- setOutput("stderr", error.stderr ?? "");
152394
- setOutput("duration", error.durationMs ?? 0);
152442
+ const err = error;
152443
+ setOutput("exitCode", err.exitCode === void 0 ? -1 : err.exitCode);
152444
+ setOutput("stdout", err.stdout ?? "");
152445
+ setOutput("stderr", err.stderr ?? "");
152446
+ setOutput("duration", err.durationMs ?? 0);
152395
152447
  }
152396
152448
  }
152397
152449
  });
@@ -152418,7 +152470,7 @@ const openInExplorer = createAction({
152418
152470
  icon: "",
152419
152471
  meta: {}
152420
152472
  });
152421
- const openInExplorerRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152473
+ const openInExplorerRunner = createActionRunner(async ({ log, inputs, setOutput, abortSignal }) => {
152422
152474
  log(`Opening ${inputs.path}`);
152423
152475
  return new Promise((resolve, reject) => {
152424
152476
  let command = "";
@@ -152426,8 +152478,14 @@ const openInExplorerRunner = createActionRunner(async ({ log, inputs, setOutput
152426
152478
  if (p === "win32") command = `start "" "${inputs.path}"`;
152427
152479
  else if (p === "darwin") command = `open "${inputs.path}"`;
152428
152480
  else command = `xdg-open "${inputs.path}"`;
152429
- (0, node_child_process.exec)(command, (error) => {
152481
+ (0, node_child_process.exec)(command, { signal: abortSignal }, (error) => {
152430
152482
  if (error) {
152483
+ if (abortSignal.aborted) {
152484
+ const abortError = /* @__PURE__ */ new Error("Aborted");
152485
+ abortError.name = "AbortError";
152486
+ reject(abortError);
152487
+ return;
152488
+ }
152431
152489
  log(`Error opening path: ${error.message}`);
152432
152490
  setOutput("message", error.message);
152433
152491
  resolve();
package/dist/index.mjs CHANGED
@@ -89405,7 +89405,7 @@ const runWithLiveLogs = async (command, args, execaOptions, log, hooks, abortSig
89405
89405
  TERM: "xterm-256color",
89406
89406
  FORCE_STDERR_LOGGING: "1"
89407
89407
  },
89408
- cancelSignal: abortSignal
89408
+ cancelSignal: abortSignal ?? execaOptions.cancelSignal
89409
89409
  });
89410
89410
  hooks?.onCreated?.(subprocess);
89411
89411
  subprocess.stdout?.on("data", (data) => {
@@ -151147,16 +151147,32 @@ const zip = createAction({
151147
151147
  meta: {}
151148
151148
  });
151149
151149
  const zipRunner = createActionRunner(async ({ log, inputs, setOutput, abortSignal }) => {
151150
- abortSignal.addEventListener("abort", () => {
151151
- throw new Error("Aborted");
151152
- });
151153
- const output = createWriteStream(inputs.output);
151150
+ const { folder, output: outputPath } = inputs;
151151
+ if (!folder) throw new Error("Missing folder");
151152
+ if (!outputPath) throw new Error("Missing output path");
151153
+ if (abortSignal.aborted) {
151154
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151155
+ abortError.name = "AbortError";
151156
+ throw abortError;
151157
+ }
151158
+ const output = createWriteStream(outputPath);
151154
151159
  const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
151155
151160
  return new Promise((resolve, reject) => {
151161
+ const onAbort = () => {
151162
+ try {
151163
+ archive.abort();
151164
+ } catch {}
151165
+ try {
151166
+ output.destroy();
151167
+ } catch {}
151168
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151169
+ abortError.name = "AbortError";
151170
+ reject(abortError);
151171
+ };
151172
+ abortSignal.addEventListener("abort", onAbort);
151156
151173
  output.on("close", function() {
151157
- console.log(archive.pointer() + " total bytes");
151158
- console.log("archiver has been finalized and the output file descriptor has closed.");
151159
- setOutput("path", inputs.output);
151174
+ abortSignal.removeEventListener("abort", onAbort);
151175
+ setOutput("path", outputPath);
151160
151176
  resolve();
151161
151177
  });
151162
151178
  output.on("end", function() {
@@ -151164,9 +151180,13 @@ const zipRunner = createActionRunner(async ({ log, inputs, setOutput, abortSigna
151164
151180
  });
151165
151181
  archive.on("warning", function(err) {
151166
151182
  if (err.code === "ENOENT") console.log("Archiver warning: ENOENT");
151167
- else reject(err);
151183
+ else {
151184
+ abortSignal.removeEventListener("abort", onAbort);
151185
+ reject(err);
151186
+ }
151168
151187
  });
151169
151188
  archive.on("error", function(err) {
151189
+ abortSignal.removeEventListener("abort", onAbort);
151170
151190
  reject(err);
151171
151191
  });
151172
151192
  archive.on("entry", function(data) {
@@ -151176,7 +151196,7 @@ const zipRunner = createActionRunner(async ({ log, inputs, setOutput, abortSigna
151176
151196
  log("finish");
151177
151197
  });
151178
151198
  archive.pipe(output);
151179
- archive.directory(inputs.folder, false);
151199
+ archive.directory(folder, false);
151180
151200
  archive.finalize();
151181
151201
  });
151182
151202
  });
@@ -151202,18 +151222,31 @@ const zipV2 = createAction({
151202
151222
  meta: {}
151203
151223
  });
151204
151224
  const zipV2Runner = createActionRunner(async ({ log, inputs, setOutput, abortSignal, paths }) => {
151205
- abortSignal.addEventListener("abort", () => {
151206
- throw new Error("Aborted");
151207
- });
151225
+ if (abortSignal.aborted) {
151226
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151227
+ abortError.name = "AbortError";
151228
+ throw abortError;
151229
+ }
151208
151230
  const outputDir = paths.cache;
151209
151231
  const outputFile = join(outputDir, "output.zip");
151210
151232
  console.log("outputFile", outputFile);
151211
151233
  const output = createWriteStream(outputFile);
151212
151234
  const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
151213
151235
  return new Promise((resolve, reject) => {
151236
+ const onAbort = () => {
151237
+ try {
151238
+ archive.abort();
151239
+ } catch {}
151240
+ try {
151241
+ output.destroy();
151242
+ } catch {}
151243
+ const abortError = /* @__PURE__ */ new Error("Aborted");
151244
+ abortError.name = "AbortError";
151245
+ reject(abortError);
151246
+ };
151247
+ abortSignal.addEventListener("abort", onAbort);
151214
151248
  output.on("close", function() {
151215
- console.log(archive.pointer() + " total bytes");
151216
- console.log("archiver has been finalized and the output file descriptor has closed.");
151249
+ abortSignal.removeEventListener("abort", onAbort);
151217
151250
  setOutput("path", outputFile);
151218
151251
  resolve();
151219
151252
  });
@@ -151222,9 +151255,13 @@ const zipV2Runner = createActionRunner(async ({ log, inputs, setOutput, abortSig
151222
151255
  });
151223
151256
  archive.on("warning", function(err) {
151224
151257
  if (err.code === "ENOENT") console.log("Archiver warning: ENOENT");
151225
- else reject(err);
151258
+ else {
151259
+ abortSignal.removeEventListener("abort", onAbort);
151260
+ reject(err);
151261
+ }
151226
151262
  });
151227
151263
  archive.on("error", function(err) {
151264
+ abortSignal.removeEventListener("abort", onAbort);
151228
151265
  reject(err);
151229
151266
  });
151230
151267
  archive.on("entry", function(data) {
@@ -152098,20 +152135,34 @@ const unzip = createAction({
152098
152135
  icon: "",
152099
152136
  meta: {}
152100
152137
  });
152101
- const unzipRunner = createActionRunner(async ({ log, inputs, setOutput, cwd }) => {
152102
- console.log("inputs", inputs);
152103
- console.log("inputs.file", inputs.file);
152138
+ const unzipRunner = createActionRunner(async ({ log, inputs, setOutput, cwd, abortSignal }) => {
152139
+ if (abortSignal.aborted) {
152140
+ const abortError = /* @__PURE__ */ new Error("Aborted");
152141
+ abortError.name = "AbortError";
152142
+ throw abortError;
152143
+ }
152104
152144
  const file = inputs.file;
152105
- console.log("file", file);
152106
152145
  const output = join(cwd);
152107
- console.log("file", file);
152108
- console.log("output", output);
152109
152146
  log("Unzip file", inputs.file, "to", output);
152110
152147
  const zip = new import_node_stream_zip.default.async({ file });
152111
- const bytes = await zip.extract(null, output);
152112
- await zip.close();
152113
- console.log("bytes", bytes);
152114
- setOutput("output", output);
152148
+ const onAbort = () => {
152149
+ zip.close().catch(() => {});
152150
+ };
152151
+ abortSignal.addEventListener("abort", onAbort);
152152
+ try {
152153
+ await zip.extract(null, output);
152154
+ await zip.close();
152155
+ setOutput("output", output);
152156
+ } catch (e) {
152157
+ if (abortSignal.aborted) {
152158
+ const abortError = /* @__PURE__ */ new Error("Aborted");
152159
+ abortError.name = "AbortError";
152160
+ throw abortError;
152161
+ }
152162
+ throw e;
152163
+ } finally {
152164
+ abortSignal.removeEventListener("abort", onAbort);
152165
+ }
152115
152166
  });
152116
152167
  const copy = createAction({
152117
152168
  id: "fs:copy",
@@ -152181,18 +152232,10 @@ const copy = createAction({
152181
152232
  icon: "",
152182
152233
  meta: {}
152183
152234
  });
152184
- const copyRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152235
+ const copyRunner = createActionRunner(async ({ log, inputs, setOutput, abortSignal }) => {
152185
152236
  log("");
152186
152237
  const from = inputs.from;
152187
152238
  let to = inputs.to;
152188
- let fromIsAFile = false;
152189
- try {
152190
- if ((await stat(from)).isFile()) fromIsAFile = true;
152191
- } catch (e) {
152192
- log("Error getting file stats", e);
152193
- throw e;
152194
- }
152195
- const fromFileName = fromIsAFile ? basename(from) : "";
152196
152239
  if (!from) {
152197
152240
  log("From", from);
152198
152241
  throw new Error("Missing source");
@@ -152201,6 +152244,14 @@ const copyRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152201
152244
  log("To", to);
152202
152245
  throw new Error("Missing destination");
152203
152246
  }
152247
+ let fromIsAFile = false;
152248
+ try {
152249
+ if ((await stat(from)).isFile()) fromIsAFile = true;
152250
+ } catch (e) {
152251
+ log("Error getting file stats", e);
152252
+ throw e;
152253
+ }
152254
+ const fromFileName = fromIsAFile ? basename(from) : "";
152204
152255
  if (fromIsAFile) try {
152205
152256
  if ((await stat(to)).isDirectory()) to = join(to, fromFileName);
152206
152257
  } catch (e) {}
@@ -152263,7 +152314,7 @@ const remove = createAction({
152263
152314
  icon: "",
152264
152315
  meta: {}
152265
152316
  });
152266
- const removeRunner = createActionRunner(async ({ log, inputs }) => {
152317
+ const removeRunner = createActionRunner(async ({ log, inputs, abortSignal }) => {
152267
152318
  log("");
152268
152319
  const from = inputs.from;
152269
152320
  log("Removing", from, inputs.recursive);
@@ -152380,10 +152431,11 @@ const runRunner = createActionRunner(async ({ log, inputs, setOutput, abortSigna
152380
152431
  console.log("error", error);
152381
152432
  if (inputs.stopOnError === true) throw error;
152382
152433
  else if (error) {
152383
- setOutput("exitCode", error.exitCode === void 0 ? -1 : error.exitCode);
152384
- setOutput("stdout", error.stdout ?? "");
152385
- setOutput("stderr", error.stderr ?? "");
152386
- setOutput("duration", error.durationMs ?? 0);
152434
+ const err = error;
152435
+ setOutput("exitCode", err.exitCode === void 0 ? -1 : err.exitCode);
152436
+ setOutput("stdout", err.stdout ?? "");
152437
+ setOutput("stderr", err.stderr ?? "");
152438
+ setOutput("duration", err.durationMs ?? 0);
152387
152439
  }
152388
152440
  }
152389
152441
  });
@@ -152410,7 +152462,7 @@ const openInExplorer = createAction({
152410
152462
  icon: "",
152411
152463
  meta: {}
152412
152464
  });
152413
- const openInExplorerRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152465
+ const openInExplorerRunner = createActionRunner(async ({ log, inputs, setOutput, abortSignal }) => {
152414
152466
  log(`Opening ${inputs.path}`);
152415
152467
  return new Promise((resolve, reject) => {
152416
152468
  let command = "";
@@ -152418,8 +152470,14 @@ const openInExplorerRunner = createActionRunner(async ({ log, inputs, setOutput
152418
152470
  if (p === "win32") command = `start "" "${inputs.path}"`;
152419
152471
  else if (p === "darwin") command = `open "${inputs.path}"`;
152420
152472
  else command = `xdg-open "${inputs.path}"`;
152421
- exec(command, (error) => {
152473
+ exec(command, { signal: abortSignal }, (error) => {
152422
152474
  if (error) {
152475
+ if (abortSignal.aborted) {
152476
+ const abortError = /* @__PURE__ */ new Error("Aborted");
152477
+ abortError.name = "AbortError";
152478
+ reject(abortError);
152479
+ return;
152480
+ }
152423
152481
  log(`Error opening path: ${error.message}`);
152424
152482
  setOutput("message", error.message);
152425
152483
  resolve();