Skip to content

Commit 284ccd9

Browse files
authored
Merge pull request #156 from amitport/patch-1
CP-1962 support jspm.config as array
2 parents 72b5fc5 + fbb16a7 commit 284ccd9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/init.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ module.exports = function(files, basePath, jspm, client, emitter) {
8888

8989
var packagesPath = path.normalize(basePath + '/' + jspm.packages + '/');
9090
var browserPath = path.normalize(basePath + '/' + jspm.browser);
91-
var configPath = path.normalize(basePath + '/' + jspm.config);
91+
var configFiles = Array.isArray(jspm.config) ? jspm.config : [jspm.config];
92+
var configPaths = configFiles.map(function(config) {
93+
return path.normalize(basePath + '/' + config);
94+
});
9295

9396
// Add SystemJS loader and jspm config
9497
function getLoaderPath(fileName){
@@ -99,8 +102,13 @@ module.exports = function(files, basePath, jspm, client, emitter) {
99102
return packagesPath + fileName + '.js';
100103
}
101104
}
102-
files.unshift(createPattern(configPath));
103-
105+
106+
Array.prototype.unshift.apply(files,
107+
configPaths.map(function(configPath) {
108+
return createPattern(configPath)
109+
})
110+
);
111+
104112
// Needed for JSPM 0.17 beta
105113
if(jspm.browser) {
106114
files.unshift(createPattern(browserPath));

test/testInit.spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ describe('jspm plugin init', function(){
3939
expect(files[3].included).toEqual(true);
4040
});
4141

42+
it('should support an array of config files', function() {
43+
jspm.config = ['custom_config.js', 'another_config.js'];
44+
files = [];
45+
initJspm(files, basePath, jspm, client, emitter);
46+
expect(normalPath(files[4].pattern)).toEqual(normalPath(basePath + '/custom_config.js'));
47+
expect(normalPath(files[5].pattern)).toEqual(normalPath(basePath + '/another_config.js'));
48+
});
49+
4250
it('should add adapter.js to the top of the files array', function(){
4351
expect(normalPath(files[2].pattern)).toEqual(normalPath(basePath + '/src/adapter.js'));
4452
expect(files[2].included).toEqual(true);

0 commit comments

Comments
 (0)