2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-10 15:21:03 +00:00

Exposes buildApp as a programmatic api for npm, and also shifted the main function from cli.js to within buildApp

Merge branch 'zweicoder-expose-main'
This commit is contained in:
Jia Hao 2016-01-24 20:42:26 +08:00
commit 3fa34dead5
4 changed files with 35 additions and 43 deletions

View File

@ -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",

View File

@ -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);
},

View File

@ -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}`);
});
}

3
src/index.js Normal file
View File

@ -0,0 +1,3 @@
import buildApp from './buildApp';
export default buildApp;