當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript async-ora.asyncOra函數代碼示例

本文整理匯總了TypeScript中@electron-forge/async-ora.asyncOra函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript asyncOra函數的具體用法?TypeScript asyncOra怎麽用?TypeScript asyncOra使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了asyncOra函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

export default async (dir: string) => {
  await asyncOra('Initializing NPM Module', async () => {
    const packageJSON = await readPackageJSON(path.resolve(__dirname, '../../../tmpl'));
    packageJSON.productName = packageJSON.name = path.basename(dir).toLowerCase();
    packageJSON.author = await username();
    setInitialForgeConfig(packageJSON);

    packageJSON.scripts.lint = 'echo "No linting configured"';

    d('writing package.json to:', dir);
    await fs.writeJson(path.resolve(dir, 'package.json'), packageJSON, { spaces: 2 });
  });

  await asyncOra('Installing NPM Dependencies', async () => {
    d('installing dependencies');
    await installDepList(dir, deps);

    d('installing devDependencies');
    await installDepList(dir, devDeps, true);

    d('installing exact dependencies');
    for (const packageName of exactDevDeps) {
      await installDepList(dir, [packageName], true, true);
    }
  });
};
開發者ID:jangocheng,項目名稱:electron-forge,代碼行數:26,代碼來源:init-npm.ts

示例2: async

export default async ({
  dir = process.cwd(),
  interactive = false,
}: LintOptions) => {
  asyncOra.interactive = interactive;

  let success = true;
  let result = null;

  await asyncOra('Linting Application', async (lintSpinner) => {
    const resolvedDir = await resolveDir(dir);
    if (!resolvedDir) {
      throw 'Failed to locate lintable Electron application';
    }

    dir = resolvedDir;

    d('executing "run lint" in dir:', dir);
    try {
      await yarnOrNpmSpawn(['run', 'lint'], {
        stdio: process.platform === 'win32' ? 'inherit' : 'pipe',
        cwd: dir,
      });
    } catch (err) {
      lintSpinner.fail();
      success = false;
      result = err;
    }
  });

  if (!success) {
    throw result;
  }
};
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:34,代碼來源:lint.ts

示例3: async

export default async (
  buildPath: string,
  electronVersion: string,
  platform: ForgePlatform,
  arch: ForgeArch,
  config: Partial<RebuildOptions> = {},
) => {
  await asyncOra('Preparing native dependencies', async (rebuildSpinner) => {
    const rebuilder = rebuild(Object.assign({}, config, {
      buildPath,
      electronVersion,
      arch,
    }));
    const { lifecycle } = rebuilder;

    let found = 0;
    let done = 0;

    const redraw = () => {
      rebuildSpinner.text = `Preparing native dependencies: ${done} / ${found}`; // eslint-disable-line
    };

    lifecycle.on('module-found', () => { found += 1; redraw(); });
    lifecycle.on('module-done', () => { done += 1; redraw(); });

    await rebuilder;
  });
};
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:28,代碼來源:rebuild.ts

示例4: async

export default async (dir: string) => {
  await asyncOra('Initializing Project Directory', async (initSpinner) => {
    d('creating directory:', dir);
    await fs.mkdirs(dir);

    const files = await fs.readdir(dir);
    if (files.length !== 0) {
      d('found', files.length, 'files in the directory.  warning the user');
      initSpinner.stop(logSymbols.warning);
      throw `The specified path: "${dir}" is not empty, do you wish to continue?`;
    }
  });
};
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:13,代碼來源:init-directory.ts

示例5: asyncOra

(async () => {
  let goodSystem;
  await asyncOra('Checking your system', async (ora) => {
    goodSystem = await checkSystem(ora);
  });

  if (!goodSystem) {
    console.error(('It looks like you are missing some dependencies you need to get Electron running.\n' +
                  'Make sure you have git installed and Node.js version 6.0.0+').red);
    process.exit(1);
  }

  program.parse(process.argv);
})();
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:14,代碼來源:electron-forge.ts

示例6: async

  const forgeSpawn = async () => {
    let electronExecPath = require(path.resolve(dir, 'node_modules/electron'));

    // If a plugin has taken over the start command let's stop here
    const spawnedPluginChild = await forgeConfig.pluginInterface.overrideStartLogic({
      dir,
      appPath,
      interactive,
      enableLogging,
      args,
      runAsNode,
      inspect,
    });
    if (typeof spawnedPluginChild === 'string') {
      electronExecPath = spawnedPluginChild;
    } else if (spawnedPluginChild) {
      await runHook(forgeConfig, 'postStart', spawnedPluginChild);
      return spawnedPluginChild;
    }

    const spawnOpts = {
      cwd: dir,
      stdio: 'inherit',
      env: Object.assign({}, process.env, enableLogging ? {
        ELECTRON_ENABLE_LOGGING: 'true',
        ELECTRON_ENABLE_STACK_DUMPING: 'true',
      } : {}) as NodeJS.ProcessEnv,
    };

    if (runAsNode) {
      spawnOpts.env.ELECTRON_RUN_AS_NODE = 'true';
    } else {
      delete spawnOpts.env.ELECTRON_RUN_AS_NODE;
    }

    if (inspect) {
      args = ['--inspect' as (string|number)].concat(args);
    }

    let spawned!: ChildProcess;

    await asyncOra('Launching Application', async () => {
      spawned = spawn(electronExecPath, [appPath].concat(args as string[]), spawnOpts);
    });

    await runHook(forgeConfig, 'postStart', spawned);
    return spawned;
  };
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:48,代碼來源:start.ts

示例7: async

export default async (dir: string) => {
  await asyncOra('Initializing Git Repository', async () => {
    await new Promise(async (resolve, reject) => {
      if (await fs.pathExists(path.resolve(dir, '.git'))) {
        d('.git directory already exists, skipping git initialization');
        return resolve();
      }
      d('executing "git init" in directory:', dir);
      exec('git init', {
        cwd: dir,
      }, (err) => {
        if (err) return reject(err);
        resolve();
      });
    });
  });
};
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:17,代碼來源:init-git.ts

示例8: async

export default async (dir: string, { copyCIFiles }: InitStarterFilesOptions) => {
  await asyncOra('Copying Starter Files', async () => {
    const tmplPath = path.resolve(__dirname, '../../../tmpl');

    d('creating directory:', path.resolve(dir, 'src'));
    await fs.mkdirs(path.resolve(dir, 'src'));
    const rootFiles = ['_gitignore'];
    if (copyCIFiles) rootFiles.push(...['_travis.yml', '_appveyor.yml']);
    const srcFiles = ['index.js', 'index.html'];

    for (const file of rootFiles) {
      await copy(path.resolve(tmplPath, file), path.resolve(dir, file.replace(/^_/, '.')));
    }
    for (const file of srcFiles) {
      await copy(path.resolve(tmplPath, file), path.resolve(dir, 'src', file));
    }
  });
};
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:18,代碼來源:init-starter-files.ts

示例9: async

export default async ({
  dir = process.cwd(),
  appPath = '.',
  interactive = false,
  enableLogging = false,
  args = [],
  runAsNode = false,
  inspect = false,
}: StartOptions) => {
  asyncOra.interactive = interactive;

  await asyncOra('Locating Application', async () => {
    const resolvedDir = await resolveDir(dir);
    if (!resolvedDir) {
      throw 'Failed to locate startable Electron application';
    }
    dir = resolvedDir;
  });

  const packageJSON = await readPackageJSON(dir);

  if (!packageJSON.version) {
    throw `Please set your application's 'version' in '${dir}/package.json'.`;
  }

  const forgeConfig = await getForgeConfig(dir);

  await rebuild(
    dir,
    getElectronVersion(packageJSON),
    process.platform as ForgePlatform,
    process.arch as ForgeArch,
    forgeConfig.electronRebuildConfig,
  );

  await runHook(forgeConfig, 'generateAssets');

  let electronExecPath = path.resolve(dir, 'node_modules/electron/cli');

  // If a plugin has taken over the start command let's stop here
  const spawnedPluginChild = await forgeConfig.pluginInterface.overrideStartLogic({
    dir,
    appPath,
    interactive,
    enableLogging,
    args,
    runAsNode,
    inspect,
  });
  if (typeof spawnedPluginChild === 'string') {
    electronExecPath = spawnedPluginChild;
  } else if (spawnedPluginChild) {
    return spawnedPluginChild;
  }

  const spawnOpts = {
    cwd: dir,
    stdio: 'inherit',
    env: Object.assign({}, process.env, enableLogging ? {
      ELECTRON_ENABLE_LOGGING: 'true',
      ELECTRON_ENABLE_STACK_DUMPING: 'true',
    } : {}) as NodeJS.ProcessEnv,
  };

  if (runAsNode) {
    spawnOpts.env.ELECTRON_RUN_AS_NODE = 'true';
  } else {
    delete spawnOpts.env.ELECTRON_RUN_AS_NODE;
  }

  if (inspect) {
    args = ['--inspect' as (string|number)].concat(args);
  }

  let spawned!: ChildProcess;

  await asyncOra('Launching Application', async () => {
    spawned = spawn(process.execPath, [electronExecPath, appPath].concat(args as string[]), spawnOpts);
  });

  return spawned;
};
開發者ID:jangocheng,項目名稱:electron-forge,代碼行數:82,代碼來源:start.ts

示例10: async

const publish = async ({
  dir = process.cwd(),
  interactive = false,
  makeOptions = {},
  publishTargets = undefined,
  dryRun = false,
  dryRunResume = false,
  makeResults = undefined,
  outDir,
}: PublishOptions) => {
  asyncOra.interactive = interactive;

  if (dryRun && dryRunResume) {
    throw 'Can\'t dry run and resume a dry run at the same time';
  }
  if (dryRunResume && makeResults) {
    throw 'Can\'t resume a dry run and use the provided makeResults at the same time';
  }

  const forgeConfig = await getForgeConfig(dir);
  let packageJSON = await readMutatedPackageJson(dir, forgeConfig);

  const calculatedOutDir = outDir || getCurrentOutDir(dir, forgeConfig);
  const dryRunDir = path.resolve(calculatedOutDir, 'publish-dry-run');

  if (dryRunResume) {
    d('attempting to resume from dry run');
    const publishes = await PublishState.loadFromDirectory(dryRunDir, dir);
    for (const publishStates of publishes) {
      d('publishing for given state set');
      await publish({
        dir,
        interactive,
        publishTargets,
        makeOptions,
        dryRun: false,
        dryRunResume: false,
        makeResults: publishStates.map(({ state }) => state),
      });
    }
    return;
  }
  
  if (!makeResults) {
    d('triggering make');
    makeResults = await make(Object.assign({
      dir,
      interactive,
    }, makeOptions));
  } else {
    // Restore values from dry run
    d('restoring publish settings from dry run');

    for (const makeResult of makeResults) {
      packageJSON = makeResult.packageJSON;
      makeOptions.platform = makeResult.platform;
      makeOptions.arch = makeResult.arch;

      for (const makePath of makeResult.artifacts) {
        if (!await fs.pathExists(makePath)) {
          throw `Attempted to resume a dry run but an artifact (${makePath}) could not be found`;
        }
      }
    }
  }

  if (dryRun) {
    d('saving results of make in dry run state', makeResults);
    await fs.remove(dryRunDir);
    await PublishState.saveToDirectory(dryRunDir, makeResults, dir);
    return;
  }

  const resolvedDir = await resolveDir(dir);
  if (!resolvedDir) {
    throw 'Failed to locate publishable Electron application';
  }
  dir = resolvedDir;

  const testPlatform = makeOptions.platform || process.platform as ForgePlatform;
  if (!publishTargets) {
    publishTargets = (forgeConfig.publishers || []);
      // .filter(publisher => (typeof publisher !== 'string' && publisher.platforms) ? publisher.platforms.indexOf(testPlatform) !== -1 : true);
  }
  publishTargets = publishTargets.map((target) => {
    if (typeof target === 'string') return { name: target };
    return target;
  }) as (IForgeResolvablePublisher | IForgePublisher)[];

  for (const publishTarget of publishTargets) {
    let publisher: PublisherBase<any>;
    if ((publishTarget as IForgePublisher).__isElectronForgePublisher) {
      publisher = publishTarget as any;
    } else {
      const resolvablePublishTarget = publishTarget as IForgeResolvablePublisher;
      let publisherModule: any;
      await asyncOra(`Resolving publish target: ${`${resolvablePublishTarget.name}`.cyan}`, async () => { // eslint-disable-line no-loop-func
        try {
          publisherModule = require(resolvablePublishTarget.name);
        } catch (err) {
//.........這裏部分代碼省略.........
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:101,代碼來源:publish.ts


注:本文中的@electron-forge/async-ora.asyncOra函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。