commit 3d66e4f1b499abe8655ef6a1053ffd6d0d5879e2 Author: Tommy Parnell Date: Wed Feb 10 20:49:42 2016 -0500 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3da2b49 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +wixFiles diff --git a/README.md b/README.md new file mode 100644 index 0000000..a04d900 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# HydroCarbon + + diff --git a/app.js b/app.js new file mode 100644 index 0000000..0955ea1 --- /dev/null +++ b/app.js @@ -0,0 +1,4 @@ +module.exports = { + exec: require('./exec.js'), + generator: require('../generator.js') +} \ No newline at end of file diff --git a/exec.js b/exec.js new file mode 100644 index 0000000..ec53b8b --- /dev/null +++ b/exec.js @@ -0,0 +1,46 @@ +var fs = require('fs'), + when = require('when'), + _ = require('underscore'); +var main = function (options) { + var heatFiles = options.heatFiles; + var candleFiles = options.candleFiles; + var lightFiles = options.lightFiles; + var heatCommands = options.heatCommands || null; + var candleCommands = options.candleCommands || null; + var lightCommands = options.lightCommands || null; + if(!heatCommands){ + if(!heatFiles || !_.isArray(heatFiles) || heatFiles.length < 1 ){ + throw "heat files are required if no commands are passed"; + } + checkFiles(heatFiles); + } + + if(!candleFiles || !_.isArray(candleFiles) || candleFiles.length < 1 ){ + throw "candle files are required" + } + if(!lightFiles || !_.isArray(lightFiles) || lightFiles.length < 1 ){ + throw "light files are required" + } + + checkFiles(candleFiles); + checkFiles(lightFiles); +} +var checkFiles = function(files){ + _.each(files, (file)=>{ + if(!checkFile(file)){ + throw "error finding file" + file; + } + }); +} +var checkFile = function (file) { + if (file || file.length < 1) { + return false; + } + try { + fs.access(file, fs.R_OK); //will error if doesnt exist + //todo async? + return true; + } catch (error) { + return false; + } +} \ No newline at end of file diff --git a/generator.js b/generator.js new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/generator.js @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/heatfile.rsp b/heatfile.rsp new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/heatfile.rsp @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..750822d --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "HydroCarbon", + "version": "0.0.0", + "description": "HydroCarbon", + "main": "app.js", + "author": { + "name": "parne", + "email": "" + }, + "dependencies": { + "underscore": "^1.8.3", + "when": "^3.7.7" + } +}