Version React iso-fonctionnelle
This commit is contained in:
1
js/util/index.js
Normal file
1
js/util/index.js
Normal file
@ -0,0 +1 @@
|
||||
exports.System = require('./system');
|
31
js/util/system.js
Normal file
31
js/util/system.js
Normal file
@ -0,0 +1,31 @@
|
||||
var fs = require('fs');
|
||||
var cp = require('child_process');
|
||||
|
||||
/**
|
||||
* Load a JSON file
|
||||
*
|
||||
* @param filePath The path of the json file
|
||||
* @return Promise
|
||||
*/
|
||||
exports.loadJSONFile = function(filePath) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.readFile(filePath, 'utf8', function(err, fileContent) {
|
||||
if(err) return reject(err);
|
||||
try {
|
||||
var json = JSON.parse(fileContent);
|
||||
return resolve(json);
|
||||
} catch(err) {
|
||||
return reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
exports.runApp = function(execPath) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
cp.exec(execPath, function(err) {
|
||||
if(err) return reject(err);
|
||||
return resolve();
|
||||
});
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user