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


TypeScript utils-fs.mkdirp函數代碼示例

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


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

示例1: preRunChecks

  protected async preRunChecks(runinfo: CommandInstanceInfo) {
    if (!this.project) {
      throw new FatalException('Cannot use Cordova outside a project directory.');
    }

    const { loadConfigXml } = await import('../../lib/integrations/cordova/config');

    await this.checkCordova(runinfo);

    // Check for www folder
    if (this.project.directory) {
      const wwwPath = path.join(this.integration.root, 'www');
      const wwwExists = await pathExists(wwwPath); // TODO: hard-coded

      if (!wwwExists) {
        const tasks = this.createTaskChain();

        tasks.next(`Creating ${strong(prettyPath(wwwPath))} directory for you`);
        await mkdirp(wwwPath);
        tasks.end();
      }
    }

    const conf = await loadConfigXml(this.integration);
    conf.resetContentSrc();
    await conf.save();
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:27,代碼來源:base.ts

示例2: run

  async run(inputs: CommandLineInputs, options: CommandLineOptions) {
    await remove(STAGING_DIRECTORY);
    await mkdirp(STAGING_DIRECTORY);

    const projectTypes: ProjectType[] = ['angular', 'ionic-angular', 'ionic1'];
    const baseCtx = await generateContext();

    for (const projectType of projectTypes) {
      // TODO: possible to do this without a physical directory?
      const ctx = { ...baseCtx, execPath: path.resolve(PROJECTS_DIRECTORY, projectType) };
      const executor = await loadExecutor(ctx, []);

      const location = await executor.namespace.locate([]);
      const formatter = new NamespaceSchemaHelpFormatter({ location, namespace: executor.namespace });
      const formatted = await formatter.serialize();
      const projectJson = { type: projectType, ...formatted };

      // TODO: `serialize()` from base formatter isn't typed properly
      projectJson.commands = await Promise.all(projectJson.commands.map(async cmd => this.extractCommand(cmd as CommandHelpSchema)));
      projectJson.commands.sort((a, b) => strcmp(a.name, b.name));

      await writeFile(path.resolve(STAGING_DIRECTORY, `${projectType}.json`), JSON.stringify(projectJson, undefined, 2) + '\n', { encoding: 'utf8' });
    }

    process.stdout.write(`${chalk.green('Done.')}\n`);
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:26,代碼來源:index.ts

示例3: sendMessage

export async function sendMessage({ config, ctx }: SendMessageDeps, msg: IPCMessage) {
  const dir = path.dirname(config.p);
  await mkdirp(dir);
  const fd = await open(path.resolve(dir, 'helper.log'), 'a');
  const p = fork(ctx.binPath, ['_', '--no-interactive'], { stdio: ['ignore', fd, fd, 'ipc'] });

  p.send(msg);
  p.disconnect();
  p.unref();
}
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:10,代碼來源:helper.ts

示例4: run

  async run(inputs: CommandLineInputs, options: CommandLineOptions): Promise<void> {
    const { getGeneratedPrivateKeyPath } = await import('../../lib/ssh');

    const { bits, annotation } = options;

    const keyPath = inputs[0] ? expandPath(String(inputs[0])) : await getGeneratedPrivateKeyPath(this.env.config.get('user.id'));
    const keyPathDir = path.dirname(keyPath);
    const pubkeyPath = `${keyPath}.pub`;

    if (!(await pathExists(keyPathDir))) {
      await mkdirp(keyPathDir, 0o700 as any); // tslint:disable-line
      this.env.log.msg(`Created ${strong(prettyPath(keyPathDir))} directory for you.`);
    }

    if (await pathExists(keyPath)) {
      const confirm = await this.env.prompt({
        type: 'confirm',
        name: 'confirm',
        message: `Key ${strong(prettyPath(keyPath))} exists. Overwrite?`,
      });

      if (confirm) {
        await unlink(keyPath);
      } else {
        this.env.log.msg(`Not overwriting ${strong(prettyPath(keyPath))}.`);
        return;
      }
    }

    this.env.log.info(
      'Enter a passphrase for your private key.\n' +
      `You will be prompted to provide a ${strong('passphrase')}, which is used to protect your private key should you lose it. (If someone has your private key, they can impersonate you!) Passphrases are recommended, but not required.\n`
    );

    const shellOptions = { stdio: 'inherit', showCommand: false, showError: false };
    await this.env.shell.run('ssh-keygen', ['-q', '-t', String(options['type']), '-b', String(bits), '-C', String(annotation), '-f', keyPath], shellOptions);

    this.env.log.nl();

    this.env.log.rawmsg(
      `Private Key (${strong(prettyPath(keyPath))}): Keep this safe!\n` +
      `Public Key (${strong(prettyPath(pubkeyPath))}): Give this to all your friends!\n\n`
    );

    this.env.log.ok('A new pair of SSH keys has been generated!');
    this.env.log.nl();

    this.env.log.msg(
      `${strong('Next steps:')}\n` +
      ` * Add your public key to Ionic: ${input('ionic ssh add ' + prettyPath(pubkeyPath))}\n` +
      ` * Use your private key for secure communication with Ionic: ${input('ionic ssh use ' + prettyPath(keyPath))}`
    );
  }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:53,代碼來源:generate.ts

示例5: ensureDirectory

 private async ensureDirectory(p: string) {
   if (!(await pathExists(p))) {
     await mkdirp(p, 0o700 as any); // tslint:disable-line
     this.env.log.msg(`Created ${strong(prettyPath(p))} directory for you.`);
   }
 }
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:6,代碼來源:generate.ts

示例6: mkdirp

 .map(dir => mkdirp(dir));
開發者ID:driftyco,項目名稱:ionic-cli,代碼行數:1,代碼來源:resources.ts


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