Skip to content

Commit

Permalink
replaced es6-promise with Q; removed gulp-shell which was blacklisted…
Browse files Browse the repository at this point in the history
… and replaced with child_process.spawn
  • Loading branch information
a11smiles committed May 12, 2016
1 parent 9e8af88 commit 09ced91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
28 changes: 15 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

var _ = require('lodash'),
gulp = require('gulp'),
shell = require('gulp-shell'),
gutil = require('gulp-util'),
fileExists = require('file-exists'),
file = require('gulp-file');
file = require('gulp-file'),
Q = require('Q');

var spawn = require('child_process').spawn;

require('es6-promise').polyfill();

var PLUGIN_NAME = 'config-transform';

Expand Down Expand Up @@ -67,6 +68,7 @@ function setup(options) {
}

function createProj(options) {
var deferred = Q.defer();

var _project = '<Project ToolsVersion="4.0" DefaultTargets="Demo" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><UsingTask TaskName="TransformXml" AssemblyFile="{assemblyFile}"/><Target Name="Transform"><TransformXml Source="{source}" Transform="{transform}" Destination="{destination}"/></Target></Project>';

Expand All @@ -76,13 +78,13 @@ function createProj(options) {
.replace('{transform}', options.transform)
.replace('{destination}', options.destination);

return Promise.all([
new Promise(function(resolve, reject) {
file('_msbuild.proj', _project, { src: true })
.pipe(gulp.dest('.'))
.on('end', resolve)
})
]);
file('_msbuild.proj', _project, { src: true })
.pipe(gulp.dest('.'))
.on('end', function() {
deferred.resolve();
});

return deferred.promise;
}

function transform(options) {
Expand All @@ -100,9 +102,9 @@ function transform(options) {

setup(_options);

return createProj(_options).then(function() {
return gulp.task('transform', shell.task(_options.msBuildPath + ' ./_msbuild.proj /t:Transform'));
});
createProj(_options).then(function() {
spawn(_options.msBuildPath, ['./_msbuild.proj', '/t:Transform'], {stdio: 'inherit'});
}).done();
}

module.exports = transform;
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
"homepage": "https://github.com/a11smiles/gulp-config-transform",
"dependencies": {
"gulp": "^3.8.6",
"gulp-shell": "^0.5.1",
"gulp-util": "^3.0.7",
"lodash": "^3.9.3",
"file-exists": "1.0.0",
"gulp-file": "0.2.0",
"es6-promise": "*"
"q": "1.4.1"
}
}

0 comments on commit 09ced91

Please sign in to comment.