Browse Source

allow imports from hidden directories

better-aggressive
Rich Harris 9 years ago
parent
commit
0b628da2d9
  1. 4
      src/utils/path.js
  2. 1
      test/function/hidden-directories/.foo/bar.js
  3. 3
      test/function/hidden-directories/_config.js
  4. 3
      test/function/hidden-directories/main.js

4
src/utils/path.js

@ -58,12 +58,10 @@ export function resolve ( ...paths ) {
} else { } else {
const parts = path.split( /[\/\\]/ ); const parts = path.split( /[\/\\]/ );
while ( parts[0] && parts[0][0] === '.' ) { while ( parts[0] === '.' || parts[0] === '..' ) {
const part = parts.shift(); const part = parts.shift();
if ( part === '..' ) { if ( part === '..' ) {
resolvedParts.pop(); resolvedParts.pop();
} else if ( part !== '.' ) {
throw new Error( `Unexpected path part (${part})` );
} }
} }

1
test/function/hidden-directories/.foo/bar.js

@ -0,0 +1 @@
export default 42;

3
test/function/hidden-directories/_config.js

@ -0,0 +1,3 @@
module.exports = {
description: 'allows imports from directories with leading "." character'
};

3
test/function/hidden-directories/main.js

@ -0,0 +1,3 @@
import bar from './.foo/bar';
assert.equal( bar, 42 );
Loading…
Cancel
Save