Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use ParentPath on file copy if available #1579

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
],
"dependencies": {
"@types/express": "^4.17.21",
"@types/node": "^20.14.10",
"@types/opener": "^1.4.3"
}
}
4 changes: 3 additions & 1 deletion src/vite/copyAssetsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export function copyAssetsPlugin(options: AlphaTabVitePluginOptions): Plugin {
files
.filter(f => f.isFile())
.map(async file => {
const sourceFilename = path.join(file.path, file.name);
// node v20.12.0 has parentPath pointing to the path (not the file)
// see https://github.com/nodejs/node/pull/50976
const sourceFilename = path.join(file.parentPath ?? file.path, file.name);
await fs.promises.copyFile(sourceFilename, path.join(outputPath!, subdir, file.name));
})
);
Expand Down
7 changes: 5 additions & 2 deletions src/webpack/AlphaTabWebPackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export class AlphaTabWebPackPlugin {
alphaTab: {} as any
} satisfies webPackWithAlphaTab;

if ('alphaTab' in compiler.webpack.util.serialization.register) { // prevent multi registration
if ('alphaTab' in compiler.webpack.util.serialization.register) {
// prevent multi registration
webPackWithAlphaTab.alphaTab = compiler.webpack.util.serialization.register.alphaTab;
} else {
(compiler.webpack.util.serialization.register as any).alphaTab = webPackWithAlphaTab.alphaTab;
Expand Down Expand Up @@ -262,7 +263,9 @@ export class AlphaTabWebPackPlugin {
files
.filter(f => f.isFile())
.map(async file => {
const sourceFilename = path.join(file.path, file.name);
// node v20.12.0 has parentPath pointing to the path (not the file)
// see https://github.com/nodejs/node/pull/50976
const sourceFilename = path.join(file.parentPath ?? file.path, file.name);
await fs.promises.copyFile(sourceFilename, path.join(outputPath!, subdir, file.name));
const assetFileName = subdir + '/' + file.name;
const existingAsset = compilation.getAsset(assetFileName);
Expand Down
2 changes: 1 addition & 1 deletion test/bundler/Vite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Vite', () => {

for (const file of dir) {
if (file.isFile()) {
const text = await fs.promises.readFile(path.join(file.path, file.name), 'utf8');
const text = await fs.promises.readFile(path.join(file.parentPath ?? file.path, file.name), 'utf8');

if (file.name.startsWith('index-')) {
// ensure new worker has worker import
Expand Down
2 changes: 1 addition & 1 deletion test/bundler/WebPack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('WebPack', () => {

for (const file of dir) {
if (file.isFile()) {
const text = await fs.promises.readFile(path.join(file.path, file.name), 'utf8');
const text = await fs.promises.readFile(path.join(file.parentPath ?? file.path, file.name), 'utf8');

if (file.name.startsWith('app-')) {
// ensure new worker has worker import
Expand Down