stopping for now

This commit is contained in:
Tommy Parnell
2016-02-18 00:15:18 -05:00
parent 6fe959f1c3
commit 2f2c6bb6f8
6 changed files with 88 additions and 11 deletions

1
.gitignore vendored
View File

@@ -1,2 +1 @@
node_modules
wixFiles

13
Gulpfile.js Normal file
View File

@@ -0,0 +1,13 @@
var gulp = require('gulp');
var unzip = require('gulp-unzip');
var request = require('request');
var fs = require('fs');
gulp.task('download', function () {
return request('http://wixtoolset.org/downloads/v3.11.0.129/wix311-binaries.zip').pipe(fs.createWriteStream('wixToolset.zip'));
});
gulp.task('getwix',['download'], function(){
return gulp.src("wixToolset.zip")
.pipe(unzip())
.pipe(gulp.dest('./wixFiles'));
});

View File

@@ -1,3 +1,4 @@
# HydroCarbon
simple wrapper over wix. You can see a working demo [here](https://github.com/tparnell8/GulpBuildForDotNet)

4
app.js
View File

@@ -1,4 +1,4 @@
module.exports = {
exec: require('./exec.js'),
generator: require('../generator.js')
}
generator: require('./generator.js')
}

75
exec.js
View File

@@ -4,9 +4,15 @@
'use strict';
var fs = require('fs'),
when = require('when'),
nodefn = require('when/node'),
_ = require('underscore'),
path = require('path'),
child_process = require('child_process');
var logger = function(log){
if(log){
console.log(log);
}
}
var main = function (options) {
var heatFiles = options.heatFiles;
var candleFiles = options.candleFiles;
@@ -14,14 +20,19 @@ var main = function (options) {
var heatCommands = options.heatCommands || null;
var candleCommands = options.candleCommands || null;
var lightCommands = options.lightCommands || null;
var heatPath = options.heatPath || path.normalize(__dirname + "/heat.exe");
var lightPath = options.lightPath || path.normalize(__dirname + "/light.exe");
var candlePath = options.candlePath || path.normalize(__dirname + "/candle.exe");
var heatPath = options.heatPath || __dirname + "/wixFiles/heat.exe";
var lightPath = options.lightPath || __dirname + "/wixFiles/light.exe";
var candlePath = options.candlePath || __dirname + "/wixFiles/candle.exe";
var cb = options.callback || function(){};
var version = options.version;
if(version){
process.env.BUILD_VERSION = version;
}
if(!heatCommands){
if(!heatFiles || !_.isArray(heatFiles) || heatFiles.length < 1 ){
throw "heat files are required if no commands are passed";
}
checkFiles(heatFiles);
// checkFiles(heatFiles);
}
if(!candleCommands){
@@ -30,7 +41,7 @@ var main = function (options) {
throw "candle files are required";
}
checkFiles(candleCommands);
//checkFiles(candleCommands);
}
@@ -40,11 +51,57 @@ var main = function (options) {
throw "light files are required";
}
checkFiles(lightFiles);
//checkFiles(lightFiles);
}
child_process.execFileSync(heatPath, heatCommands? heatCommands: _.map(heatFiles, (file)=>`@${path.normalize(file)}`));
child_process.execFile(path.normalize(heatPath), heatCommands? heatCommands: _.map(heatFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
logger(stdout);
logger(stderr);
if(err){
throw err;
}
child_process.execFile(path.normalize(candlePath), candleCommands? candleCommands: _.map(candleFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
logger(stdout);
logger(stderr);
if(err){
throw err;
}
child_process.execFile(path.normalize(lightPath), lightCommands? lightCommands: _.map(lightFiles, (file)=>`@${path.normalize(file)}`), (err, stdout, stderr)=>{
logger(stdout);
logger(stderr);
if(err){
throw err;
}
});
});
});
//todo: figure out how to use promises while capturing stderr on the catch
/*
var liftedChild = nodefn.lift(child_process.execFile);
liftedChild(heatPath, heatCommands? heatCommands: _.map(heatFiles, (file)=>`@${path.normalize(file)}`))
.then((stdin, stderror)=>{
console.log(stdin);
console.log(stderror);
return liftedChild(candlePath, candleCommands? candleCommands: _.map(candleFiles, (file)=>`@${path.normalize(file)}`));
})
.then((stdin, stderror)=>{
console.log(stdin);
console.log(stderror);
return liftedChild(lightPath, lightCommands? lightCommands: _.map(lightFiles, (file)=>`@${path.normalize(file)}`));
})
.catch((a,b,c)=>{
console.log(a);
console.log(b);
console.log(c);
})*/
};
var checkFiles = function(files){
_.each(files, (file)=>{
if(!checkFile(file)){
@@ -57,10 +114,12 @@ var checkFile = function (file) {
return false;
}
try {
fs.access(file, fs.R_OK); //will error if doesnt exist
fs.access(path.normalize(file), fs.R_OK); //will error if doesnt exist
//todo async?
return true;
} catch (error) {
return false;
}
};
module.exports = main;

View File

@@ -10,5 +10,10 @@
"dependencies": {
"underscore": "^1.8.3",
"when": "^3.7.7"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-unzip": "^0.1.3",
"request": "^2.69.0"
}
}