diff --git a/package.json b/package.json index 6c9780c..c249d4d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "native", "wrapper" ], - "main": "lib/buildApp.js", + "main": "lib/index.js", "scripts": { "dev-up": "npm install && (cd app && npm install) && npm run build", "test": "gulp test", diff --git a/src/buildApp.js b/src/buildApp.js index 1e6d64a..7ca7861 100644 --- a/src/buildApp.js +++ b/src/buildApp.js @@ -2,6 +2,7 @@ import fs from 'fs'; import path from 'path'; import crypto from 'crypto'; +import optionsFactory from './options'; import packager from 'electron-packager'; import tmp from 'tmp'; import ncp from 'ncp'; @@ -31,10 +32,30 @@ function buildApp(options, callback) { async.waterfall([ callback => { - copyPlaceholderApp(options.dir, tmpPath, options.name, options.targetUrl, options.counter, options.width, options.height, options.showMenuBar, options.userAgent, callback); + optionsFactory( + options.appName, + options.targetUrl, + options.platform, + options.arch, + options.electronVersion, + options.outDir, + options.overwrite, + options.conceal, + options.icon, + options.counter, + options.width, + options.height, + options.showMenuBar, + options.userAgent, + options.honest, + callback); }, - - (tempDir, callback) => { + (options, callback) => { + copyPlaceholderApp(options.dir, tmpPath, options.name, options.targetUrl, options.counter, options.width, options.height, options.showMenuBar, options.userAgent, (error, tempDirPath) => { + callback(error, tempDirPath, options); + }); + }, + (tempDir, options, callback) => { options.dir = tempDir; packager(options, callback); }, diff --git a/src/cli.js b/src/cli.js index f2ac52d..d6fdace 100755 --- a/src/cli.js +++ b/src/cli.js @@ -2,47 +2,9 @@ import path from 'path'; import program from 'commander'; -import async from 'async'; - -import optionsFactory from './options'; import buildApp from './buildApp'; - const packageJson = require(path.join('..', 'package')); -function main(program) { - async.waterfall([ - callback => { - optionsFactory( - program.appName, - program.targetUrl, - program.platform, - program.arch, - program.electronVersion, - program.outDir, - program.overwrite, - program.conceal, - program.icon, - program.counter, - program.width, - program.height, - program.showMenuBar, - program.userAgent, - program.honest, - callback); - }, - - (options, callback) => { - buildApp(options, callback); - } - ], (error, appPath) => { - if (error) { - console.error(error); - return; - } - console.log(`App built to ${appPath}`); - }); -} - if (require.main === module) { program .version(packageJson.version) @@ -70,5 +32,11 @@ if (require.main === module) { program.help(); } - main(program); + buildApp(program, (error, appPath) => { + if (error) { + console.error(error); + return; + } + console.log(`App built to ${appPath}`); + }); } diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..8662380 --- /dev/null +++ b/src/index.js @@ -0,0 +1,3 @@ +import buildApp from './buildApp'; + +export default buildApp;