Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: 70ff7a74a8
...
compare: e17cf14e3c
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jun 28, 2013
Stephan Ziep tsort command might not available on all OS
convert source file paths to OS specifc format
9f19678
Stephan Ziep added missing dependencies e17cf14
Showing with 20 additions and 12 deletions.
  1. +3 −1 package.json
  2. +1 −1  tasks/dep-concat.js
  3. +16 −10 tasks/lib/file-graph.js
View
4 package.json
@@ -28,7 +28,9 @@
"test": "grunt test"
},
"dependencies": {
- "when": "~1.8.0"
+ "when": "~1.8.0",
+ "path": "0.4.9",
+ "tsort": ">= 0.0.1"
},
"devDependencies": {
"grunt-contrib-jshint": "0.1.1",
View
2  tasks/dep-concat.js
@@ -21,7 +21,7 @@ module.exports = function( grunt ) {
var options = this.options();
when.map( this.files, function( f ) {
- var sources = f.src.filter(function( path ) {
+ var sources = f.src.map( fileGraph.normalizePath ).filter(function( path ) {
if ( !grunt.file.exists( path )) {
grunt.log.warn( 'Source file "' + path + '" not found.' );
return false;
View
26 tasks/lib/file-graph.js
@@ -8,6 +8,7 @@
var path = require( 'path' );
var exec = require( 'child_process' ).exec;
+var tsort = require('tsort');
exports.init = function( grunt ) {
var exports = {};
@@ -97,17 +98,22 @@ exports.init = function( grunt ) {
}
}
- var command = 'echo "' + depGraphString + '" | tsort';
- exec( command, function( error, stdout, stderr ) {
- var tsortOrderedFiles = _( stdout ).words( '\n' ).reverse();
- push.apply( orderedFiles, tsortOrderedFiles );
+ var graph = tsort();
+ var unsorted = depGraphString.split( '\n' );
+ for(var i = 0; i < unsorted.length - 1; i ++) {
+ var split = unsorted[i].split( /\s+/ );
- if ( stderr !== '' ) {
- grunt.log.error( stderr );
+ if ( split[1] !== split[0] ) {
+ graph.add( split[1], split[0] );
+ } else {
+ graph.add( split[0] );
}
+ }
- callback( orderedFiles );
- });
+ var sortedGraph = graph.sort();
+ push.apply( orderedFiles, sortedGraph );
+
+ callback( orderedFiles );
};
exports.parseFile = function( filepath, options ) {
@@ -143,7 +149,7 @@ exports.init = function( grunt ) {
}
if ( fileList ) {
- var files = _.words( split[1], ',' ).map( trimElems ).map( normalizePath );
+ var files = _.words( split[1], ',' ).map( trimElems ).map( exports.normalizePath );
push.apply( fileList, files );
}
}
@@ -163,7 +169,7 @@ exports.init = function( grunt ) {
return _( str ).trim();
};
- var normalizePath = function( p ) {
+ exports.normalizePath = function( p ) {
return p.replace( /[\/\\]+/g, path.sep );
};

No commit comments for this range

Something went wrong with that request. Please try again.