Skip to content

Commit e5a8479

Browse files
committed
release(esbuild): 🏹 Release [email protected]
1 parent 72fc47c commit e5a8479

File tree

7 files changed

+34
-10
lines changed

7 files changed

+34
-10
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
issues
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
src
2-
tests
2+
tests
3+
issues

packages/esbuild-plugin-copy/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# CHANGELOG
22

3+
## Release 2.1.1
4+
5+
- BugFix: When copy with `file-to-file`, and the `to` path contains nested unexist path, the plugin will throw error as it doesnot create the nested path by `fs.ensureDirSync`.
6+
37
## Release 2.1.0
48

5-
- Feature: `Watc hMode` support for plugin-level and asset pair level.
9+
- Feature: `Watch Mode` support for plugin-level and asset pair level.
610

711
## Released 2.0.1
812

packages/esbuild-plugin-copy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esbuild-plugin-copy",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "ESBuild plugin for assets copy.",
55
"keywords": [
66
"esbuild",

packages/esbuild-plugin-copy/src/lib/esbuild-plugin-copy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const copy = (options: Partial<Options> = {}): Plugin => {
104104

105105
if (!build.initialOptions.watch) {
106106
verboseLog(
107-
`Watching mode diabled. You need to enable ${chalk.white(
107+
`Watching mode disabled. You need to enable ${chalk.white(
108108
'build.watch'
109109
)} option for watch mode to work.`,
110110
verbose

packages/esbuild-plugin-copy/src/lib/handler.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export function copyOperationHandler(
5757
const isToPathDir = path.extname(baseToPath) === '';
5858

5959
const composedDistDirPath = isToPathDir
60-
? path.resolve(
60+
? // /RESOLVE_FROM_DIR/SPECIFIED_TO_DIR/LEFT_FILE_STRUCTURE
61+
path.resolve(
6162
// base resolve destination dir
6263
outDirResolveFrom,
6364
// configures destination dir
@@ -72,11 +73,7 @@ export function copyOperationHandler(
7273
baseToPath
7374
);
7475

75-
dryRun
76-
? void 0
77-
: isToPathDir
78-
? fs.ensureDirSync(path.dirname(composedDistDirPath))
79-
: void 0;
76+
dryRun ? void 0 : fs.ensureDirSync(path.dirname(composedDistDirPath));
8077

8178
dryRun ? void 0 : fs.copyFileSync(sourcePath, composedDistDirPath);
8279

packages/esbuild-plugin-copy/tests/plugin.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,27 @@ describe('CopyPlugin:Core', async () => {
372372

373373
expect(d1).toEqual(['hello.txt', 'index.js']);
374374
});
375+
it.only('should copy from file to file with nested dest dir', async () => {
376+
const outDir = tmp.dirSync().name;
377+
378+
await builder(
379+
outDir,
380+
{ outdir: outDir },
381+
{
382+
assets: {
383+
from: path.resolve(__dirname, './fixtures/assets/note.txt'),
384+
to: './unexist/nest/dir/hello.txt',
385+
},
386+
resolveFrom: 'out',
387+
verbose: false,
388+
dryRun: false,
389+
}
390+
);
391+
392+
const d1 = fs.readdirSync(path.join(outDir, 'unexist/nest/dir'), {});
393+
394+
expect(d1).toEqual(['hello.txt']);
395+
});
375396
});
376397

377398
describe('CopyPlugin:Utils', async () => {

0 commit comments

Comments
 (0)