2014-12-05 19:26:30 -05:00
|
|
|
var which = require('which');
|
2015-06-17 07:24:59 -04:00
|
|
|
var spawnSync = require('child_process').spawnSync;
|
2014-12-05 19:26:30 -05:00
|
|
|
|
2015-06-17 07:24:59 -04:00
|
|
|
module.exports.detect = function(gulp) {
|
2014-12-05 19:26:30 -05:00
|
|
|
var DART_SDK = false;
|
|
|
|
try {
|
|
|
|
which.sync('dart');
|
|
|
|
if (process.platform === 'win32') {
|
|
|
|
DART_SDK = {
|
2015-05-08 22:23:49 -04:00
|
|
|
ANALYZER: 'dartanalyzer.bat',
|
2015-08-31 12:28:10 -04:00
|
|
|
DARTDOCGEN: 'dartdoc.bat',
|
2015-05-14 16:14:45 -04:00
|
|
|
DARTFMT: 'dartfmt.bat',
|
|
|
|
PUB: 'pub.bat',
|
2015-06-09 11:49:44 -04:00
|
|
|
VM: 'dart.exe'
|
2014-12-05 19:26:30 -05:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
DART_SDK = {
|
2015-05-08 22:23:49 -04:00
|
|
|
ANALYZER: 'dartanalyzer',
|
2015-08-31 12:28:10 -04:00
|
|
|
DARTDOCGEN: 'dartdoc',
|
2015-05-14 16:14:45 -04:00
|
|
|
DARTFMT: 'dartfmt',
|
|
|
|
PUB: 'pub',
|
|
|
|
VM: 'dart'
|
2014-12-05 19:26:30 -05:00
|
|
|
};
|
|
|
|
}
|
2015-06-17 07:24:59 -04:00
|
|
|
console.log('Dart SDK detected:');
|
2014-12-05 19:26:30 -05:00
|
|
|
} catch (e) {
|
|
|
|
console.log('Dart SDK is not available, Dart tasks will be skipped.');
|
|
|
|
var gulpTaskFn = gulp.task.bind(gulp);
|
|
|
|
gulp.task = function (name, deps, fn) {
|
|
|
|
if (name.indexOf('.dart') === -1) {
|
|
|
|
return gulpTaskFn(name, deps, fn);
|
|
|
|
} else {
|
|
|
|
return gulpTaskFn(name, function() {
|
|
|
|
console.log('Dart SDK is not available. Skipping task: ' + name);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return DART_SDK;
|
|
|
|
}
|
2015-06-17 07:24:59 -04:00
|
|
|
|
|
|
|
module.exports.logVersion = function(dartSdk) {
|
|
|
|
console.log('DART SDK:') ;
|
|
|
|
console.log('- dart: ' + spawnSync(dartSdk.VM, ['--version']).stderr.toString().replace(/\n/g, ''));
|
|
|
|
console.log('- pub: ' + spawnSync(dartSdk.PUB, ['--version']).stdout.toString().replace(/\n/g, ''));
|
|
|
|
}
|