• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.api类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@electron-forge/core.api的典型用法代码示例。如果您正苦于以下问题:TypeScript api类的具体用法?TypeScript api怎么用?TypeScript api使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了api类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: files

(async () => {
  let dir = process.cwd();
  program
    .version(require('../package.json').version)
    .arguments('[name]')
    .option('-t, --template [name]', 'Name of the forge template to use')
    .option('-c, --copy-ci-files', 'Whether to copy the templated CI files (defaults to false)', false)
    .action((name) => {
      if (!name) return;
      if (path.isAbsolute(name)) {
        dir = name;
      } else {
        dir = path.resolve(dir, name);
      }
    })
    .parse(process.argv);

  const initOpts: InitOptions = {
    dir,
    interactive: true,
    copyCIFiles: !!program.copyCiFiles,
  };
  if (program.template) initOpts.template = program.template;

  await api.init(initOpts);
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:26,代码来源:electron-forge-init.ts


示例2: async

(async () => {
  let repo!: string;

  program
    .version(require('../package.json').version)
    .arguments('[repository]')
    .option('--prerelease', 'Fetch prerelease versions')
    .action((repository) => {
      repo = repository;
    })
    .parse(process.argv);
  
  const chooseAsset = async (assets: InstallAsset[]) => {
    const choices: { name: string, value: string }[] = [];
    assets.forEach((asset) => {
      choices.push({ name: asset.name, value: asset.id });
    });
    const { assetID } = await inquirer.createPromptModule()<{ assetID: string }>({
      choices,
      type: 'list',
      name: 'assetID',
      message: 'Multiple potential assets found, please choose one from the list below:'.cyan,
    });

    return assets.find(asset => asset.id === assetID)!;
  };

  await api.install({
    chooseAsset,
    repo,
    interactive: true,
    prerelease: program.prerelease,
  });
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:34,代码来源:electron-forge-install.ts


示例3: if

(async () => {
  let dir = process.cwd();

  program
    .version(require('../package.json').version)
    .arguments('[cwd]')
    .option('-a, --arch [arch]', 'Target architecture')
    .option('-p, --platform [platform]', 'Target build platform')
    .action((cwd) => {
      if (!cwd) return;
      if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
        dir = cwd;
      } else if (fs.existsSync(path.resolve(dir, cwd))) {
        dir = path.resolve(dir, cwd);
      }
    })
    .parse(process.argv);

  const packageOpts: PackageOptions = {
    dir,
    interactive: true,
  };
  if (program.arch) packageOpts.arch = program.arch;
  if (program.platform) packageOpts.platform = program.platform;

  await api.package(packageOpts);
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:27,代码来源:electron-forge-package.ts


示例4: if

(async () => {
  let dir = process.cwd();
  program
    .version(require('../package.json').version)
    .arguments('[cwd]')
    .option('--target [target[,target...]]', 'The comma-separated deployment targets, defaults to "github"')
    .option('--dry-run', 'Triggers a publish dry run which saves state and doesn\'t upload anything')
    .option('--from-dry-run', 'Attempts to publish artifacts from the last saved dry run')
    .allowUnknownOption(true)
    .action((cwd) => {
      if (!cwd) return;
      if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
        dir = cwd;
      } else if (fs.existsSync(path.resolve(dir, cwd))) {
        dir = path.resolve(dir, cwd);
      }
    })
    .parse(process.argv);

  const publishOpts: PublishOptions = {
    dir,
    interactive: true,
    dryRun: program.dryRun,
    dryRunResume: program.fromDryRun,
  };
  if (program.target) publishOpts.publishTargets = program.target.split(',');

  publishOpts.makeOptions = getMakeOptions();

  await api.publish(publishOpts);
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:31,代码来源:electron-forge-publish.ts


示例5: if

(async () => {
  let dir = process.cwd();
  program
    .version(require('../package.json').version)
    .arguments('[cwd]')
    .action((cwd) => {
      if (!cwd) return;
      if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
        dir = cwd;
      } else if (fs.existsSync(path.resolve(dir, cwd))) {
        dir = path.resolve(dir, cwd);
      }
    })
    .parse(process.argv);

  await api.lint({
    dir,
    interactive: true,
  });
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:20,代码来源:electron-forge-lint.ts


示例6:

(async () => {
  let dir = process.cwd();
  program
    .version(require('../package.json').version)
    .arguments('[name]')
    .action((name) => {
      if (!name) return;
      if (path.isAbsolute(name)) {
        dir = name;
      } else {
        dir = path.resolve(dir, name);
      }
    })
    .parse(process.argv);

  await api.import({
    dir,
    interactive: true,
  });
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:20,代码来源:electron-forge-import.ts


示例7: launch

(async () => {
  let commandArgs = process.argv;
  let appArgs;

  const doubleDashIndex = process.argv.indexOf('--');
  if (doubleDashIndex !== -1) {
    commandArgs = process.argv.slice(0, doubleDashIndex);
    appArgs = process.argv.slice(doubleDashIndex + 1);
  }

  let dir = process.cwd();
  program
    .version(require('../package.json').version)
    .arguments('[cwd]')
    .option('-p, --app-path <path>', 'Override the path to the Electron app to launch (defaults to \'.\')')
    .option('-l, --enable-logging', 'Enable advanced logging.  This will log internal Electron things')
    .option('-n, --run-as-node', 'Run the Electron app as a Node.JS script')
    .option('--vscode', 'Used to enable arg transformation for debugging Electron through VSCode.  Do not use yourself.')
    .option('-i, --inspect-electron', 'Triggers inspect mode on Electron to allow debugging the main process.  Electron >1.7 only')
    .action((cwd) => {
      if (!cwd) return;
      if (path.isAbsolute(cwd) && fs.existsSync(cwd)) {
        dir = cwd;
      } else if (fs.existsSync(path.resolve(dir, cwd))) {
        dir = path.resolve(dir, cwd);
      }
    })
    .parse(commandArgs);

  program.on('--help', () => {
    console.log('  Any arguments found after "--" will be passed to the Electron app, e.g.');
    console.log('');
    console.log('    $ electron-forge /path/to/project -l -- -d -f foo.txt');
    console.log('');
    console.log('  will pass the arguments "-d -f foo.txt" to the Electron app');
  });

  const opts: StartOptions = {
    dir,
    interactive: true,
    enableLogging: !!program.enableLogging,
    runAsNode: !!program.runAsNode,
    inspect: !!program.inspectElectron,
  };

  if (program.vscode && appArgs) {
    // Args are in the format ~arg~ so we need to strip the "~"
    appArgs = appArgs
      .map(arg => arg.substr(1, arg.length - 2))
      .filter(arg => arg.length > 0);
  }

  if (program.appPath) opts.appPath = program.appPath;
  if (appArgs) opts.args = appArgs;

  const spawned = await api.start(opts);

  await new Promise((resolve) => {
    spawned.on('exit', (code: number) => {
      if ((spawned as any).restarted) return;
      if (code !== 0) {
        process.exit(code);
      }
      resolve();
    });
  });
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:67,代码来源:electron-forge-start.ts


示例8: getMakeOptions

  (async () => {
    const makeOpts = getMakeOptions();

    await api.make(makeOpts);
  })();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:5,代码来源:electron-forge-make.ts



注:本文中的@electron-forge/core.api类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ipc-main-internal.ipcMainInternal类代码示例发布时间:2022-05-28
下一篇:
TypeScript async-ora.OraImpl类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap