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


TypeScript fs-extra.pathExistsSync函數代碼示例

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


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

示例1: expect

      .then(function () {
        const cwd = process.cwd();
        expect(cwd).to.not.match(/foo/, 'does not use app name for directory name');
        expect(!fs.pathExistsSync(path.join(cwd, 'foo')), 'does not create new directory with app name');

        expect(cwd).to.match(/bar/, 'uses given directory name');
        expect(fs.pathExistsSync(path.join(cwd, 'bar')), 'creates new directory with specified name');

        const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
        expect(pkgJson.name).to.equal('foo', 'uses app name for package name');
      });
開發者ID:RoPP,項目名稱:angular-cli,代碼行數:11,代碼來源:new.spec.ts

示例2: expect

      .then(() => {
        const cwd = process.cwd();
        expect(cwd).not.toMatch(/foo/, 'does not use app name for directory name');
        expect(fs.pathExistsSync(path.join(cwd, 'foo'))).toBe(false, 'does not create new directory with app name');

        expect(cwd).toMatch(/bar/, 'uses given directory name');
        expect(fs.pathExistsSync(path.join(cwd, '..', 'bar'))).toBe(true, 'creates new directory with specified name');

        const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
        expect(pkgJson.name).toBe('foo', 'uses app name for package name');
      })
開發者ID:alexspring123,項目名稱:angular-cli,代碼行數:11,代碼來源:new.spec.ts

示例3: transformHeaders

      return Object.keys(this.definition!.subscriptions!).map(name => {
        const subscription = this.definition!.subscriptions![name]

        const url =
          typeof subscription.webhook === 'string'
            ? subscription.webhook
            : subscription.webhook.url
        const headers =
          typeof subscription.webhook === 'string'
            ? []
            : transformHeaders(subscription.webhook.headers)

        let query = subscription.query
        if (subscription.query.endsWith('.graphql')) {
          const queryPath = path.join(this.definitionDir, subscription.query)
          if (!fs.pathExistsSync(queryPath)) {
            throw new Error(
              `Subscription query ${queryPath} provided in subscription "${name}" in prisma.yml does not exist.`,
            )
          }
          query = fs.readFileSync(queryPath, 'utf-8')
        }

        return {
          name,
          query,
          headers,
          url,
        }
      })
開發者ID:nunsie,項目名稱:prisma,代碼行數:30,代碼來源:PrismaDefinition.ts

示例4: expect

 .then(() => {
   const testPath =
     path.join(root, 'tmp', 'foo', 'src', 'app', 'mycomp', 'mycomp.component.ts');
   expect(pathExistsSync(testPath)).toBe(true);
   const contents = readFileSync(testPath, 'utf8');
   expect(contents.indexOf('selector: \'test-mycomp\'') === -1).toBe(false);
 })
開發者ID:dzonatan,項目名稱:angular-cli,代碼行數:7,代碼來源:generate-component.spec.ts

示例5: PluginPath

 plugins = plugins.concat((cli.plugins || []).map(name => {
   let pluginPath = path.join(this.config.root, 'node_modules', name)
   if (!fs.pathExistsSync(pluginPath)) {
     pluginPath = path.join(this.config.root, '../../', 'node_modules', name)
   }
   return new PluginPath({output: this.out, type: 'core', path: pluginPath})
 }))
開發者ID:dhruvcodeword,項目名稱:prisma,代碼行數:7,代碼來源:CorePlugins.ts

示例6: readDefinition

export async function readDefinition(
  filePath: string,
  args: Args,
  out: IOutput = new Output(),
  envVars?: any,
): Promise<{ definition: PrismaDefinition; rawJson: any }> {
  if (!fs.pathExistsSync(filePath)) {
    throw new Error(`${filePath} could not be found.`)
  }
  const file = fs.readFileSync(filePath, 'utf-8')
  const json = yaml.safeLoad(file) as PrismaDefinition
  // we need this copy because populateJson runs inplace
  const jsonCopy = { ...json }

  const vars = new Variables(filePath, args, out, envVars)
  const populatedJson = await vars.populateJson(json)
  if (populatedJson.custom) {
    delete populatedJson.custom
  }
  const valid = validate(populatedJson)
  // TODO activate as soon as the backend sends valid yaml
  if (!valid) {
    debugger
    let errorMessage =
      `Invalid prisma.yml file` + '\n' + printErrors(validate.errors!)
    throw new Error(errorMessage)
  }

  cache[file] = populatedJson
  return {
    definition: populatedJson,
    rawJson: jsonCopy,
  }
}
開發者ID:nunsie,項目名稱:prisma,代碼行數:34,代碼來源:yaml.ts

示例7: seed

  async seed(
    serviceName: string,
    stageName: string,
    reset: boolean = false,
    workspaceSlug?: string,
  ) {
    const seed = this.definition.definition!.seed
    if (!seed) {
      throw new Error(
        `In order to seed, you need to provide a "seed" property in your prisma.yml`,
      )
    }
    if (seed.import && seed.run) {
      throw new Error(
        `Please provider either seed.import or seed.run but not both at the same time`,
      )
    }

    if (seed.import) {
      const source = path.join(this.config.definitionDir, seed.import)

      debug(source)

      if (!source.endsWith('.zip') && !source.endsWith('.graphql')) {
        throw new Error(`Source must end with .zip or .graphql`)
      }

      if (!fs.pathExistsSync(source)) {
        throw new Error(`Path ${source} does not exist`)
      }

      const token = this.definition.getToken(serviceName, stageName)

      if (reset) {
        await this.reset(serviceName, stageName)
      }

      if (source.endsWith('.zip')) {
        await this.import(source, serviceName, stageName, token, workspaceSlug)
      } else if (source.endsWith('.graphql')) {
        await this.executeQuery(
          source,
          serviceName,
          stageName,
          token,
          workspaceSlug,
        )
      }
    }

    if (seed.run) {
      if (reset) {
        await this.reset(serviceName, stageName)
      }

      await this.run(seed.run)
    }
  }
開發者ID:ahmb84,項目名稱:prisma,代碼行數:58,代碼來源:Seeder.ts

示例8: expect

      .then(() => {
        expect(fs.pathExistsSync(path.join(testPath, '+my-route/my-route.component.ts')))
          .to.equal(true);
        expect(fs.pathExistsSync(path.join(testPath, '+my-route/+my-other/my-other.component.ts')))
          .to.equal(true);
        expect(fs.pathExistsSync(path.join(testPath, '+my-route/+my-other/+my-third/my-third.component.ts')))
          .to.equal(true);

        const appContent = fs.readFileSync(path.join(testPath, 'foo.component.ts'), 'utf-8');
        const myRouteContent = fs.readFileSync(path.join(testPath, '+my-route/my-route.component.ts'), 'utf-8');
        const myOtherRouteContent = fs.readFileSync(path.join(testPath, '+my-route/+my-other/my-other.component.ts'), 'utf-8');
        const myThirdRouteContent = fs.readFileSync(path.join(testPath, '+my-route/+my-other/+my-third/my-third.component.ts'), 'utf-8');

        expect(appContent).to.match(/@Routes\(\[[\s\S]+\/\+my-route\/\.\.\.[\s\S]+\]\)/m);
        expect(myRouteContent).to.match(/@Routes\(\[[\s\S]+\/my-other\/\.\.\.[\s\S]+\]\)/m);
        expect(myOtherRouteContent).to.match(/@Routes\(\[[\s\S]+\/my-third[^\.][\s\S]+\]\)/m);
        expect(myThirdRouteContent).to.not.include('@Routes');
      });
開發者ID:RoPP,項目名稱:angular-cli,代碼行數:18,代碼來源:generate-route.spec.ts

示例9: ng

        return ng(['generate', 'module', 'm', '--app', 'other']).then(() => {
          const expectedModule = path.join(appRoot, 'other', 'src', 'm', 'm.module.ts');
          expect(pathExistsSync(expectedModule)).toBe(true);

          return ng(['generate', 'component', 'm/c', '--app', 'other', '--module', 'm']).then(() => {
            expect(pathExistsSync(path.join(appRoot, 'other', 'src', 'm', 'c', 'c.component.ts'))).toBe(true);
            expect(readFileSync(expectedModule, 'utf-8')).toContain(`import { CComponent } from './c/c.component'`);
          });
        }).then(done, done.fail);
開發者ID:3L4CKD4RK,項目名稱:angular-cli,代碼行數:9,代碼來源:generate-component.spec.ts

示例10: teardown

export function teardown(path: string) {
  process.chdir(root);

  if (fs.pathExistsSync(path)) {
    return fs.remove(path);
  } else {
    return Promise.resolve();
  }
};
開發者ID:3L4CKD4RK,項目名稱:angular-cli,代碼行數:9,代碼來源:tmp.ts


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