Parcourir la source

feat(project): support building and running from chrome apps

evshiron il y a 8 ans
Parent
commit
a62bc5b4e9
4 fichiers modifiés avec 18 ajouts et 2 suppressions
  1. 6 0
      src/bin/build.ts
  2. 6 0
      src/bin/run.ts
  3. 3 1
      src/lib/Builder.ts
  4. 3 1
      src/lib/Runner.ts

+ 6 - 0
src/bin/build.ts

@@ -35,6 +35,11 @@ const argv = require('yargs')
     describe: 'Build for x64 arch',
     default: Builder.DEFAULT_OPTIONS.x64,
 })
+.option('chrome-app', {
+    type: 'boolean',
+    describe: 'Build from Chrome App',
+    default: Builder.DEFAULT_OPTIONS.chromeApp,
+})
 .option('mirror', {
     describe: 'Modify NW.js mirror',
     default: Builder.DEFAULT_OPTIONS.mirror,
@@ -57,6 +62,7 @@ const argv = require('yargs')
         linux: argv.linux,
         x86: argv.x86,
         x64: argv.x64,
+        chromeApp: argv['chrome-app'],
         mirror: argv.mirror,
         concurrent: argv.concurrent,
         mute: false,

+ 6 - 0
src/bin/run.ts

@@ -17,6 +17,11 @@ const argv = require('yargs')
     describe: 'Build for x64 arch',
     default: Runner.DEFAULT_OPTIONS.x64,
 })
+.option('chrome-app', {
+    type: 'boolean',
+    describe: 'Build from Chrome App',
+    default: Runner.DEFAULT_OPTIONS.chromeApp,
+})
 .option('mirror', {
     describe: 'Modify NW.js mirror',
     default: Runner.DEFAULT_OPTIONS.mirror,
@@ -36,6 +41,7 @@ const argv = require('yargs')
     const runner = new Runner({
         x86: argv.x86,
         x64: argv.x64,
+        chromeApp: argv['chrome-app'],
         mirror: argv.mirror,
         detached: argv.detached,
         mute: false,

+ 3 - 1
src/lib/Builder.ts

@@ -23,6 +23,7 @@ interface IBuilderOptions {
     linux?: boolean;
     x86?: boolean;
     x64?: boolean;
+    chromeApp?: boolean;
     mirror?: string;
     concurrent?: boolean;
     mute?: boolean;
@@ -36,6 +37,7 @@ export class Builder {
         linux: false,
         x86: false,
         x64: false,
+        chromeApp: false,
         mirror: Downloader.DEFAULT_OPTIONS.mirror,
         concurrent: false,
         mute: true,
@@ -101,7 +103,7 @@ export class Builder {
         }
         else {
 
-            const pkg: any = await readJsonAsync(join(this.dir, 'package.json'));
+            const pkg: any = await readJsonAsync(join(this.dir, this.options.chromeApp ? 'manifest.json' : 'package.json'));
             const config = new BuildConfig(pkg);
 
             debug('in build', 'config', config);

+ 3 - 1
src/lib/Runner.ts

@@ -14,6 +14,7 @@ import { mergeOptions, findExecutable, findFFmpeg, tmpDir, spawnAsync, extractGe
 interface IRunnerOptions {
     x86?: boolean;
     x64?: boolean;
+    chromeApp?: boolean;
     mirror?: string;
     detached?: boolean;
     mute?: boolean;
@@ -24,6 +25,7 @@ export class Runner {
     public static DEFAULT_OPTIONS: IRunnerOptions = {
         x86: false,
         x64: false,
+        chromeApp: false,
         mirror: Downloader.DEFAULT_OPTIONS.mirror,
         detached: false,
         mute: true,
@@ -47,7 +49,7 @@ export class Runner {
         ? (this.options.x86 ? 'ia32' : 'x64')
         : process.arch;
 
-        const pkg: any = await readJsonAsync(join(this.args[0], 'package.json'));
+        const pkg: any = await readJsonAsync(join(this.args[0], this.options.chromeApp ? 'manifest.json' : 'package.json'));
         const config = new BuildConfig(pkg);
 
         debug('in run', 'config', config);