bunup 0.8.9 → 0.8.10

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/cli.js CHANGED
@@ -563,7 +563,7 @@ var init_new = __esm(() => {
563
563
  // src/cli/index.ts
564
564
  import { exec } from "tinyexec";
565
565
  // package.json
566
- var version = "0.8.9";
566
+ var version = "0.8.10";
567
567
 
568
568
  // src/cli/index.ts
569
569
  init_errors();
package/dist/plugins.cjs CHANGED
@@ -410,6 +410,9 @@ function getUpdatedPackageJson(oldPackageJson, newPackageJson) {
410
410
  return JSON.stringify(newPackageJson, null, getJsonSpaceCount(oldPackageJson)) + (hasTrailingNewline ? `
411
411
  ` : "");
412
412
  }
413
+ function isDirectoryPath(filePath) {
414
+ return import_node_path.default.extname(filePath) === "";
415
+ }
413
416
 
414
417
  // src/plugins/built-in/productivity/exports.ts
415
418
  function exports2() {
@@ -637,31 +640,23 @@ function injectStyles(options) {
637
640
  };
638
641
  }
639
642
  // src/plugins/built-in/productivity/copy.ts
640
- var import_promises = require("fs/promises");
641
643
  var import_node_path3 = require("path");
642
- function copy(patterns, outDir) {
644
+ var import_node_path4 = require("path");
645
+ function copy(patterns, outPath) {
643
646
  return {
644
647
  type: "bunup",
645
648
  name: "copy",
646
649
  hooks: {
647
650
  onBuildDone: async ({ options, meta }) => {
648
- const targetDir = outDir || options.outDir;
649
- const baseDir = meta.rootDir;
651
+ const destinationPath = outPath || options.outDir;
650
652
  for (const pattern of patterns) {
651
- let globPattern = pattern;
652
- if (!pattern.includes("*") && !pattern.includes("?")) {
653
- try {
654
- const stats = await import_promises.stat(`${baseDir}/${pattern}`);
655
- if (stats.isDirectory()) {
656
- globPattern = `${pattern}/**/*`;
657
- }
658
- } catch {}
659
- }
660
- const glob = new Bun.Glob(globPattern);
661
- for await (const file of glob.scan(baseDir)) {
662
- const targetPath = `${targetDir}/${file}`;
663
- await import_promises.mkdir(import_node_path3.dirname(targetPath), { recursive: true });
664
- await Bun.write(targetPath, Bun.file(`${baseDir}/${file}`));
653
+ const glob = new Bun.Glob(pattern);
654
+ for await (const filePath of glob.scan({
655
+ cwd: meta.rootDir,
656
+ dot: true
657
+ })) {
658
+ const sourceFile = Bun.file(import_node_path3.join(meta.rootDir, filePath));
659
+ await Bun.write(outPath && isDirectoryPath(outPath) ? import_node_path3.join(destinationPath, import_node_path4.basename(filePath)) : destinationPath, sourceFile);
665
660
  }
666
661
  }
667
662
  }
@@ -415,7 +415,9 @@ declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
415
415
  /**
416
416
  * A plugin that copies files and directories to the output directory.
417
417
  *
418
+ * @param patterns - Array of glob patterns to match files for copying
419
+ * @param outPath - Optional output path. If not provided, uses the build output directory
418
420
  * @see https://bunup.dev/docs/plugins/productivity#copy
419
421
  */
420
- declare function copy(patterns: string[], outDir?: string): BunupPlugin;
422
+ declare function copy(patterns: string[], outPath?: string): BunupPlugin;
421
423
  export { shims, report, injectStyles, filterJsDtsFiles, exports, copy };
package/dist/plugins.d.ts CHANGED
@@ -415,7 +415,9 @@ declare function injectStyles(options?: InjectStylesPluginOptions): Plugin;
415
415
  /**
416
416
  * A plugin that copies files and directories to the output directory.
417
417
  *
418
+ * @param patterns - Array of glob patterns to match files for copying
419
+ * @param outPath - Optional output path. If not provided, uses the build output directory
418
420
  * @see https://bunup.dev/docs/plugins/productivity#copy
419
421
  */
420
- declare function copy(patterns: string[], outDir?: string): BunupPlugin;
422
+ declare function copy(patterns: string[], outPath?: string): BunupPlugin;
421
423
  export { shims, report, injectStyles, filterJsDtsFiles, exports, copy };
package/dist/plugins.js CHANGED
@@ -374,6 +374,9 @@ function getUpdatedPackageJson(oldPackageJson, newPackageJson) {
374
374
  return JSON.stringify(newPackageJson, null, getJsonSpaceCount(oldPackageJson)) + (hasTrailingNewline ? `
375
375
  ` : "");
376
376
  }
377
+ function isDirectoryPath(filePath) {
378
+ return path.extname(filePath) === "";
379
+ }
377
380
 
378
381
  // src/plugins/built-in/productivity/exports.ts
379
382
  function exports() {
@@ -601,31 +604,23 @@ function injectStyles(options) {
601
604
  };
602
605
  }
603
606
  // src/plugins/built-in/productivity/copy.ts
604
- import { mkdir, stat } from "fs/promises";
605
- import { dirname } from "path";
606
- function copy(patterns, outDir) {
607
+ import { join } from "path";
608
+ import { basename } from "path";
609
+ function copy(patterns, outPath) {
607
610
  return {
608
611
  type: "bunup",
609
612
  name: "copy",
610
613
  hooks: {
611
614
  onBuildDone: async ({ options, meta }) => {
612
- const targetDir = outDir || options.outDir;
613
- const baseDir = meta.rootDir;
615
+ const destinationPath = outPath || options.outDir;
614
616
  for (const pattern of patterns) {
615
- let globPattern = pattern;
616
- if (!pattern.includes("*") && !pattern.includes("?")) {
617
- try {
618
- const stats = await stat(`${baseDir}/${pattern}`);
619
- if (stats.isDirectory()) {
620
- globPattern = `${pattern}/**/*`;
621
- }
622
- } catch {}
623
- }
624
- const glob = new Bun.Glob(globPattern);
625
- for await (const file of glob.scan(baseDir)) {
626
- const targetPath = `${targetDir}/${file}`;
627
- await mkdir(dirname(targetPath), { recursive: true });
628
- await Bun.write(targetPath, Bun.file(`${baseDir}/${file}`));
617
+ const glob = new Bun.Glob(pattern);
618
+ for await (const filePath of glob.scan({
619
+ cwd: meta.rootDir,
620
+ dot: true
621
+ })) {
622
+ const sourceFile = Bun.file(join(meta.rootDir, filePath));
623
+ await Bun.write(outPath && isDirectoryPath(outPath) ? join(destinationPath, basename(filePath)) : destinationPath, sourceFile);
629
624
  }
630
625
  }
631
626
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bunup",
3
3
  "description": "⚡ A blazing-fast build tool for your libraries built with Bun.",
4
- "version": "0.8.9",
4
+ "version": "0.8.10",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist",