Skip to content

Commit

Permalink
release(esbuild): 🏹 Release [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
linbudu599 committed Mar 26, 2023
1 parent 72fc47c commit e5a8479
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/esbuild-plugin-copy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
issues
3 changes: 2 additions & 1 deletion packages/esbuild-plugin-copy/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src
tests
tests
issues
6 changes: 5 additions & 1 deletion packages/esbuild-plugin-copy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# CHANGELOG

## Release 2.1.1

- 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`.

## Release 2.1.0

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

## Released 2.0.1

Expand Down
2 changes: 1 addition & 1 deletion packages/esbuild-plugin-copy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-copy",
"version": "2.1.0",
"version": "2.1.1",
"description": "ESBuild plugin for assets copy.",
"keywords": [
"esbuild",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const copy = (options: Partial<Options> = {}): Plugin => {

if (!build.initialOptions.watch) {
verboseLog(
`Watching mode diabled. You need to enable ${chalk.white(
`Watching mode disabled. You need to enable ${chalk.white(
'build.watch'
)} option for watch mode to work.`,
verbose
Expand Down
9 changes: 3 additions & 6 deletions packages/esbuild-plugin-copy/src/lib/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export function copyOperationHandler(
const isToPathDir = path.extname(baseToPath) === '';

const composedDistDirPath = isToPathDir
? path.resolve(
? // /RESOLVE_FROM_DIR/SPECIFIED_TO_DIR/LEFT_FILE_STRUCTURE
path.resolve(
// base resolve destination dir
outDirResolveFrom,
// configures destination dir
Expand All @@ -72,11 +73,7 @@ export function copyOperationHandler(
baseToPath
);

dryRun
? void 0
: isToPathDir
? fs.ensureDirSync(path.dirname(composedDistDirPath))
: void 0;
dryRun ? void 0 : fs.ensureDirSync(path.dirname(composedDistDirPath));

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

Expand Down
21 changes: 21 additions & 0 deletions packages/esbuild-plugin-copy/tests/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,27 @@ describe('CopyPlugin:Core', async () => {

expect(d1).toEqual(['hello.txt', 'index.js']);
});
it.only('should copy from file to file with nested dest dir', async () => {
const outDir = tmp.dirSync().name;

await builder(
outDir,
{ outdir: outDir },
{
assets: {
from: path.resolve(__dirname, './fixtures/assets/note.txt'),
to: './unexist/nest/dir/hello.txt',
},
resolveFrom: 'out',
verbose: false,
dryRun: false,
}
);

const d1 = fs.readdirSync(path.join(outDir, 'unexist/nest/dir'), {});

expect(d1).toEqual(['hello.txt']);
});
});

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

0 comments on commit e5a8479

Please sign in to comment.