Skip to content

Commit

Permalink
Always use complete resolve algorithm instead of fast tricks.
Browse files Browse the repository at this point in the history
Fixes #12.
  • Loading branch information
RReverser committed Nov 14, 2014
1 parent 54a017c commit c20c1cd
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 48 deletions.
16 changes: 6 additions & 10 deletions lib/pathUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var stdUtils = exports.std = require('path'),
localRegEx = /^\.\.?\//;

exports.forceExt = function (path, ext) {
return path + (stdUtils.extname(path) ? '' : '.' + (ext || 'js'));
return path + (exports.ext(path) ? '' : '.' + ext);
};

exports.normalizePath = function (path) {
Expand All @@ -18,15 +18,11 @@ exports.relative = function (from, to) {
exports.getNodePath = function (from, to, options) {
var fromDir = from + '/..';

if (localRegEx.test(to)) {
return exports.forceExt(exports.normalizePath(stdUtils.resolve(fromDir, to)), options.defaultExt);
} else {
return exports.normalizePath(nodeResolve.sync(to, {
basedir: stdUtils.resolve('', fromDir),
extensions: (options.defaultExt !== 'js' ? ['.' + options.defaultExt] : []).concat(['.js']),
moduleDirectory: options.moduleDir
}));
}
return exports.normalizePath(nodeResolve.sync(to, {
basedir: stdUtils.resolve('', fromDir),
extensions: (options.defaultExt !== 'js' ? ['.' + options.defaultExt] : []).concat(['.js', '.json']),
moduleDirectory: options.moduleDir
}));
};

exports.ext = function (path) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pure-cjs",
"version": "1.16.0",
"version": "1.17.0",
"description": "Pure minimalistic CommonJS builder",
"bin": "./bin/pure-cjs.js",
"main": "./lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/a.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ var c = require('./c'),
url = require('url'),
Promise = require('davy');

this.topValue = require('./sub/b.js') * 2;
this.topValue = require('./b') * 2;
this.expectedValue = require('./data.json').answer;
File renamed without changes.
14 changes: 7 additions & 7 deletions test/suites/a (exports A with externals)/expected.js

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

2 changes: 1 addition & 1 deletion test/suites/a (exports A with externals)/expected.js.map

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

14 changes: 7 additions & 7 deletions test/suites/a (exports A with map and comments)/expected.js

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

Loading

0 comments on commit c20c1cd

Please sign in to comment.