Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for file: syntax #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions build/static_dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,21 @@ function addPackages(siteConfig, buildFolder) {

return readFile(path.join(fullBuildFolderPath, "package.json")).then(function(packageContents){
var json = JSON.parse(packageContents);
var filePathedDeps = siteConfig.html.dependencies;

json.dependencies = _.assign(json.dependencies || {},siteConfig.html.dependencies);
for(var depName in siteConfig.html.dependencies) {
var possibleFilePath = siteConfig.dependencies[depName];

if (_.startsWith(possibleFilePath,'file:')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use Lodash instead of startsWith or indexOf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I don't understand what you're asking. I literally wanted to know what the code is saying: Does it start with this string or not, and lodash was already required in the file. Otherwise I would have used indexOf.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should’ve been more clear; any reason not to use the native String APIs here? Not a big deal, just asking if there’s a reason to use Lodash.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability it's good.

filePathedDeps[depName] = possibleFilePath;
}
}

json.dependencies = _.assign(json.dependencies || {},filePathedDeps);

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

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

Expand Down