Skip to content

Commit

Permalink
Use correct require instance and enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jun 20, 2022
1 parent 44fbb21 commit 4e6e721
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cli/run/commandPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ async function loadAndRegisterPlugin(
try {
if (pluginText[0] == '.') pluginText = resolve(pluginText);
// Windows absolute paths must be specified as file:// protocol URL
else if (pluginText.match(/^[A-Za-z]:\\/)) pluginText = "file://" + require$$0.resolve(pluginText);
else if (pluginText.match(/^[A-Za-z]:\\/)) {
pluginText = 'file://' + require.resolve(pluginText);
}
plugin = await requireOrImport(pluginText);
} catch (err: any) {
throw new Error(`Cannot load plugin "${pluginText}": ${err.message}.`);
Expand Down
3 changes: 1 addition & 2 deletions test/cli/samples/plugin/absolute-esm/_config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
description: 'ESM CLI --plugin /absolute/path',
minNodeVersion: 12,
skipIfWindows: true,
command: `echo 'console.log(1 ? 2 : 3);' | rollup -p "\`pwd\`/my-esm-plugin.mjs={comment: 'Absolute ESM'}"`
command: `rollup main.js -p "\`pwd\`/my-esm-plugin.mjs={comment: 'Absolute ESM'}"`
};
1 change: 1 addition & 0 deletions test/cli/samples/plugin/absolute-esm/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(1 ? 2 : 3);
3 changes: 1 addition & 2 deletions test/cli/samples/plugin/absolute/_config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
description: 'CLI --plugin /absolute/path',
skipIfWindows: true,
command: `echo 'console.log(VALUE);' | rollup -p "\`pwd\`/my-plugin={VALUE: 'absolute', ZZZ: 1}"`
command: `rollup main.js -p "\`pwd\`/my-plugin={VALUE: 'absolute', ZZZ: 1}"`
};
1 change: 1 addition & 0 deletions test/cli/samples/plugin/absolute/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(VALUE);

0 comments on commit 4e6e721

Please sign in to comment.