init
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
wixFiles
|
||||
4
app.js
Normal file
4
app.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
exec: require('./exec.js'),
|
||||
generator: require('../generator.js')
|
||||
}
|
||||
46
exec.js
Normal file
46
exec.js
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
1
generator.js
Normal file
1
generator.js
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
heatfile.rsp
Normal file
1
heatfile.rsp
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
14
package.json
Normal file
14
package.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user