Skip to content

Commit 095e9a8

Browse files
committed
add support for ./ in .main
1 parent d8c05d8 commit 095e9a8

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lib/builder.js

+2
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ Builder.prototype.json = function(fn){
370370
if (self.conf) return fn(null, self.conf);
371371
try {
372372
self.conf = cache[path] = JSON.parse(str);
373+
utils.normalizeConfig(self.conf);
374+
373375
// TODO: lame, remove me
374376
if (!self._emittedConfig) {
375377
self._emittedConfig = true;

lib/utils.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@
1010
exports.stripQuotes = function(str) {
1111
if ('"' == str[0] || "'" == str[0]) return str.slice(1, -1);
1212
return str;
13-
};
13+
};
14+
15+
/**
16+
* Normalize `conf`.
17+
*
18+
* @param {Object} conf
19+
* @api private
20+
*/
21+
22+
exports.normalizeConfig = function(conf){
23+
// support "./" in main
24+
if (conf.main) conf.main = conf.main.replace(/^\.\//, '');
25+
};

test/fixtures/main/component.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "main",
33
"version": "0.0.1",
4-
"scripts": ["foo.js", "bar.js"],
5-
"main": "foo.js"
6-
}
4+
"scripts": ["./foo.js", "./bar.js"],
5+
"main": "./foo.js"
6+
}

0 commit comments

Comments
 (0)