Refactor options to seperate folders

This commit is contained in:
Jia Hao 2016-02-20 10:39:51 +08:00
parent 4663b99050
commit 6ddf84bee1
3 changed files with 24 additions and 21 deletions

View File

@ -5,7 +5,7 @@ import ncp from 'ncp';
import async from 'async';
import hasBinary from 'hasbin';
import optionsFactory from './../options';
import optionsFactory from './../options/optionsMain';
import iconBuild from './iconBuild';
import helpers from './../helpers/helpers';
import buildApp from './buildApp';

View File

@ -0,0 +1,17 @@
import url from 'url';
import validator from 'validator';
function normalizeUrl(testUrl) {
// add protocol if protocol not found
let normalized = testUrl;
const parsed = url.parse(normalized);
if (!parsed.protocol) {
normalized = 'http://' + normalized;
}
if (!validator.isURL(normalized, {require_protocol: true, require_tld: false})) {
throw `Your Url: "${normalized}" is invalid!`;
}
return normalized;
}
export default normalizeUrl;

View File

@ -1,19 +1,18 @@
import os from 'os';
import path from 'path';
import url from 'url';
import validator from 'validator';
import _ from 'lodash';
import async from 'async';
import sanitizeFilename from 'sanitize-filename';
import inferIcon from './infer/inferIcon';
import inferTitle from './infer/inferTitle';
import inferOs from './infer/inferOs';
import packageJson from './../package.json';
import inferIcon from './../infer/inferIcon';
import inferTitle from './../infer/inferTitle';
import inferOs from './../infer/inferOs';
import normalizeUrl from './normalizeUrl';
import packageJson from './../../package.json';
const {inferPlatform, inferArch} = inferOs;
const PLACEHOLDER_APP_DIR = path.join(__dirname, '../', 'app');
const PLACEHOLDER_APP_DIR = path.join(__dirname, '../../', 'app');
const ELECTRON_VERSION = '0.36.4';
const DEFAULT_APP_NAME = 'APP';
@ -100,19 +99,6 @@ function sanitizeOptions(options) {
return options;
}
function normalizeUrl(testUrl) {
// add protocol if protocol not found
let normalized = testUrl;
const parsed = url.parse(normalized);
if (!parsed.protocol) {
normalized = 'http://' + normalized;
}
if (!validator.isURL(normalized, {require_protocol: true, require_tld: false})) {
throw `Your Url: "${normalized}" is invalid!`;
}
return normalized;
}
function getFakeUserAgent() {
let userAgent;
switch (os.platform()) {