From 5605ce5c85c48a7f3e2cff30fb059f803866aec0 Mon Sep 17 00:00:00 2001 From: Kurt Blackwell Date: Fri, 1 Jul 2016 22:21:26 +0800 Subject: [PATCH] Add a test for loading config when the drive letter doesn't match after realpath. List 'fs' as external dependency. --- rollup.config.cli.js | 1 + test/cli/config-cwd-case-insensitive/_config.js | 13 +++++++++++++ test/cli/config-cwd-case-insensitive/main.js | 1 + .../config-cwd-case-insensitive/rollup.config.js | 9 +++++++++ test/test.js | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/cli/config-cwd-case-insensitive/_config.js create mode 100644 test/cli/config-cwd-case-insensitive/main.js create mode 100644 test/cli/config-cwd-case-insensitive/rollup.config.js diff --git a/rollup.config.cli.js b/rollup.config.cli.js index 0e0eed6..95e8588 100644 --- a/rollup.config.cli.js +++ b/rollup.config.cli.js @@ -22,6 +22,7 @@ export default { }) ], external: [ + 'fs', 'path', 'module', 'source-map-support' diff --git a/test/cli/config-cwd-case-insensitive/_config.js b/test/cli/config-cwd-case-insensitive/_config.js new file mode 100644 index 0000000..d07b87d --- /dev/null +++ b/test/cli/config-cwd-case-insensitive/_config.js @@ -0,0 +1,13 @@ +var os = require( 'os' ); + +function toggleCase ( s ) { + return ( s == s.toLowerCase() ) ? s.toUpperCase() : s.toLowerCase(); +} + +module.exports = { + skip: os.platform() !== 'win32', + description: "can load config with cwd that doesn't match realpath", + command: 'rollup -c', + cwd: process.cwd().replace( /^[A-Z]:\\/ig, toggleCase ), + execute: true +}; diff --git a/test/cli/config-cwd-case-insensitive/main.js b/test/cli/config-cwd-case-insensitive/main.js new file mode 100644 index 0000000..df16c1b --- /dev/null +++ b/test/cli/config-cwd-case-insensitive/main.js @@ -0,0 +1 @@ +assert.equal( ANSWER, 42 ); diff --git a/test/cli/config-cwd-case-insensitive/rollup.config.js b/test/cli/config-cwd-case-insensitive/rollup.config.js new file mode 100644 index 0000000..3cc995e --- /dev/null +++ b/test/cli/config-cwd-case-insensitive/rollup.config.js @@ -0,0 +1,9 @@ +var replace = require( 'rollup-plugin-replace' ); + +module.exports = { + entry: 'main.js', + format: 'cjs', + plugins: [ + replace({ 'ANSWER': 42 }) + ] +}; diff --git a/test/test.js b/test/test.js index 3cc959b..0ba18fe 100644 --- a/test/test.js +++ b/test/test.js @@ -376,7 +376,7 @@ describe( 'rollup', function () { var config = loadConfig( CLI + '/' + dir + '/_config.js' ); ( config.skip ? it.skip : config.solo ? it.only : it )( dir, function ( done ) { - process.chdir( path.resolve( CLI, dir ) ); + process.chdir( config.cwd || path.resolve( CLI, dir ) ); const command = 'node ' + path.resolve( __dirname, '../bin' ) + path.sep + config.command;