Skip to content

Commit 521db8b

Browse files
committed
Add support for file: syntax
1 parent ceecae6 commit 521db8b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Diff for: build/static_dist.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,28 @@ function addPackages(siteConfig, buildFolder) {
112112

113113
return readFile(path.join(fullBuildFolderPath, "package.json")).then(function(packageContents){
114114
var json = JSON.parse(packageContents);
115+
var filePathedDeps = siteConfig.html.dependencies;
116+
117+
for(var depName in siteConfig.html.dependencies) {
118+
var possibleFilePath = siteConfig.dependencies[depName];
119+
120+
if (_.startsWith(possibleFilePath,'file:')) {
121+
try {
122+
var absDir = path.resolve(possibleFilePath.substr(5));
123+
if(fs.statSync(absDir).isDirectory()) {
124+
filePathedDeps[depName] = absDir;
125+
}
126+
} catch(err) {
127+
// skip bad path
128+
}
129+
}
130+
}
115131

116-
json.dependencies = _.assign(json.dependencies || {},siteConfig.html.dependencies);
132+
json.dependencies = _.assign(json.dependencies || {},filePathedDeps);
117133

118134
return writeFile( path.join(fullBuildFolderPath, "package.json"), JSON.stringify(json) ).then(function(){
119135

120-
var deps = _.map(siteConfig.html.dependencies, function(version, packageName){
136+
var deps = _.map(filePathedDeps, function(version, packageName){
121137
return '"'+packageName+'": callIfFunction( require("'+packageName+'") )';
122138
});
123139

0 commit comments

Comments
 (0)