Skip to content

Commit

Permalink
Display dependencies and sources in canonical order
Browse files Browse the repository at this point in the history
  • Loading branch information
svanderburg committed Jan 5, 2018
1 parent 56c093e commit caf5d68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ Package.prototype.resolveDependencies = function(callback) {
* @return {Array} An array representing a list of NPM package dependencies
*/
Package.prototype.generateDependencyAST = function() {
var self = this;
var dependencies = [];

for(var dependencyName in this.providedDependencies) {
var dependency = this.providedDependencies[dependencyName];
Object.keys(self.providedDependencies).sort().forEach(function(dependencyName) {
var dependency = self.providedDependencies[dependencyName];

// For each dependency, refer to the source attribute set that defines it
var ref = new nijs.NixAttrReference({
Expand All @@ -297,7 +298,7 @@ Package.prototype.generateDependencyAST = function() {
}

dependencies.push(dependencyExpr);
}
});

if(dependencies.length == 0) {
return undefined; // If no dependencies are required, simply compose no parameter. Though not mandatory, it improves readability of the generated expression
Expand Down
7 changes: 4 additions & 3 deletions lib/SourcesCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ SourcesCache.prototype.addSource = function(source) {
* @see NixASTNode#toNixAST
*/
SourcesCache.prototype.toNixAST = function() {
var self = this;
var ast = {};

for(var identifier in this.sources) {
var source = this.sources[identifier];
Object.keys(self.sources).sort().forEach(function(identifier) {
var source = self.sources[identifier];
ast[identifier] = source.toNixAST();
}
});

return ast;
};
Expand Down

0 comments on commit caf5d68

Please sign in to comment.