Skip to content

Commit d51e2a6

Browse files
authored
Merge pull request #3969 from sniok/fix-glob-pattern
app: Fix glob pattern on windows for setup-plugins.js
2 parents 4e99e75 + d80fc71 commit d51e2a6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/scripts/setup-plugins.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ async function extractArchive(
3737
fs.mkdirSync(pluginFolder);
3838
}
3939

40+
console.log('Copying plugin to ', pluginFolder);
41+
4042
// Move the plugins contents to the plugins folder
41-
const mainLocationExpr = path.join(tmpFolder, '*', 'main.js');
43+
const mainLocationExpr = path.join(tmpFolder, '*', 'main.js').replace(/\\/g, '/');
4244
const mainLocations = glob.sync(mainLocationExpr);
4345
const mainLocation = mainLocations[0];
4446
if (mainLocation && fs.existsSync(mainLocation)) {
@@ -48,12 +50,11 @@ async function extractArchive(
4850
path.join(packageJsonLocation, 'package.json'),
4951
path.join(pluginFolder, 'package.json')
5052
);
51-
resolve();
52-
return;
53+
console.log('Copied plugin from ', packageJsonLocation, ' to ', pluginFolder);
5354
}
54-
5555
// Compatibility with legacy tarball structure
56-
if (fs.existsSync(path.join(tmpFolder, 'package', 'dist'))) {
56+
else if (fs.existsSync(path.join(tmpFolder, 'package', 'dist'))) {
57+
console.log('Found plugin with a legacy tarball structure');
5758
// Move the plugins contents to the plugins folder
5859
fs.copyFileSync(
5960
path.join(tmpFolder, 'package', 'dist', 'main.js'),
@@ -63,7 +64,15 @@ async function extractArchive(
6364
path.join(tmpFolder, 'package', 'package.json'),
6465
path.join(pluginFolder, 'package.json')
6566
);
67+
} else {
68+
console.error('Failed to find plugin content within tarball');
69+
console.error({
70+
archivePath,
71+
unarchivedPath: tmpFolder,
72+
});
73+
reject();
6674
}
75+
6776
resolve();
6877
});
6978
});

0 commit comments

Comments
 (0)