Fix #87, Fix #89 - Sanitize app name

- Appname that contains unsafe characters which will cause electron packager to hang, so we sanitize them before passing them to electron-packager
This commit is contained in:
Jia Hao 2016-01-26 09:51:39 +08:00
parent 56b7abacf8
commit 03440e9227
2 changed files with 9 additions and 2 deletions

View File

@ -43,6 +43,7 @@
"lodash": "^4.0.0",
"ncp": "^2.0.0",
"request": "^2.67.0",
"sanitize-filename": "^1.5.3",
"source-map-support": "^0.4.0",
"tmp": "0.0.28",
"validator": "^4.5.0"

View File

@ -5,6 +5,7 @@ import url from 'url';
import request from 'request';
import cheerio from 'cheerio';
import validator from 'validator';
import sanitize from 'sanitize-filename';
const TEMPLATE_APP_DIR = path.join(__dirname, '../', 'app');
const ELECTRON_VERSION = '0.36.4';
@ -69,7 +70,7 @@ function optionsFactory(name,
if (name && name.length > 0) {
options.name = name;
callback(null, options);
callback(null, sanitizeOptions(options));
return;
}
@ -81,10 +82,15 @@ function optionsFactory(name,
options.name = pageTitle;
}
callback(null, options);
callback(null, sanitizeOptions(options));
});
}
function sanitizeOptions(options) {
options.name = sanitize(options.name);
return options;
}
function detectPlatform() {
const platform = os.platform();
if (platform === 'darwin' || platform === 'win32' || platform === 'linux') {