Chargement/Sauvegarde profil via l'UI

This commit is contained in:
2015-09-18 12:13:24 +02:00
parent 383f70f7f3
commit 6c8d26139e
9 changed files with 140 additions and 13 deletions

View File

@ -10,7 +10,7 @@ var Cache = require('./cache');
* @param filePath The path of the json file
* @return Promise
*/
exports.loadJSONFile = function(filePath) {
exports.loadJSON = function(filePath) {
return new Promise(function(resolve, reject) {
fs.readFile(filePath, 'utf8', function(err, fileContent) {
if(err) return reject(err);
@ -24,6 +24,19 @@ exports.loadJSONFile = function(filePath) {
});
};
exports.saveJSON = function(filePath, obj) {
var jsonStr = JSON.stringify(obj, null, 2);
return new Promise(function(resolve, reject) {
fs.writeFile(filePath, jsonStr, function(err) {
if(err) return reject(err);
return resolve();
});
});
};
/**
* Load a INI file
*
@ -44,7 +57,18 @@ exports.loadINIFile = function(filePath) {
});
};
exports.runApp = function(execPath) {
exports.clearFreeDesktopFlags = function(exec) {
return exec.replace(/%[uUdDfFnNickvm]/g, '');
};
exports.runApp = function(execPath, opts) {
opts = opts || {};
if(opts.clearFreeDesktopFlags) {
execPath = exports.clearFreeDesktopFlags(execPath);
}
return new Promise(function(resolve, reject) {
cp.exec(execPath, function(err) {
if(err) return reject(err);