当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript cjson.load函数代码示例

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


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

示例1: parse

 public static parse(configPath:string) : Config {
   var config:Config;
   if (configPath.match(/\.json$/)) {
     config = cjson.load(configPath);
   } else if (configPath.match(/\.js$/)) {
     config = require(configPath);
   } else {
     // fallback to json parsing
     config = cjson.load(configPath);
   }
   config = this.preprocess(config);
   this.validate(config);
   return config;
 }
开发者ID:aadamsx,项目名称:typeloy,代码行数:14,代码来源:config.ts

示例2: packageJsonIsValid

export function packageJsonIsValid(
  sourceDirName: string,
  sourceDir: string,
  projectDir: string
): void {
  const packageJsonFile = path.join(sourceDir, "package.json");
  if (!fsutils.fileExistsSync(packageJsonFile)) {
    const msg = `No npm package found in functions source directory. Please run 'npm init' inside ${sourceDirName}`;
    throw new FirebaseError(msg);
  }

  try {
    const data = cjson.load(packageJsonFile);
    logger.debug("> [functions] package.json contents:", JSON.stringify(data, null, 2));
    const indexJsFile = path.join(sourceDir, data.main || "index.js");
    if (!fsutils.fileExistsSync(indexJsFile)) {
      const msg = `${path.relative(
        projectDir,
        indexJsFile
      )} does not exist, can't deploy Cloud Functions`;
      throw new FirebaseError(msg);
    }
  } catch (e) {
    const msg = `There was an error reading ${sourceDirName}${path.sep}package.json:\n\n ${
      e.message
    }`;
    throw new FirebaseError(msg);
  }
}
开发者ID:firebase,项目名称:firebase-tools,代码行数:29,代码来源:validate.ts

示例3: getRuntimeChoice

export function getRuntimeChoice(sourceDir: string): any {
  const packageJsonPath = path.join(sourceDir, "package.json");
  const loaded = cjson.load(packageJsonPath);
  const engines = loaded.engines;
  if (!engines || !engines.node) {
    return null;
    // TODO(b/129422952): Change to throw error instead of returning null
    // when engines field in package.json becomes required:
    // throw new FirebaseError(ENGINES_FIELD_REQUIRED_MSG, { exit: 1 });
  }
  const runtime = ENGINE_RUNTIMES[engines.node];
  if (!runtime) {
    throw new FirebaseError(UNSUPPORTED_NODE_VERSION_MSG, { exit: 1 });
  }

  if (runtime === "nodejs6") {
    utils.logWarning(DEPRECATION_WARNING_MSG);
  } else {
    // for any other runtime (8 or 10)
    if (functionsSDKTooOld(loaded)) {
      utils.logWarning(FUNCTIONS_SDK_VERSION_TOO_OLD_WARNING);
    }
  }
  return runtime;
}
开发者ID:firebase,项目名称:firebase-tools,代码行数:25,代码来源:runtimeChoiceSelector.ts

示例4: loadSymbols

function loadSymbols ( secpath: string ): Symbol[]
{
    try {
        var obj = cjson.load( secpath );
        var res = tv4.validateResult(obj, schema);
    } catch(ex) {
        throw new Error( secpath + ': ' + ex.message );
    }
    if (!res.valid)
        throw new Error( secpath + ': ' + res.error.message || "Invalid security file" );
    return obj;
}
开发者ID:mcanet,项目名称:blart,代码行数:12,代码来源:index.ts

示例5: getSwNavigationUrlChecker

export function getSwNavigationUrlChecker() {
  const config = loadJson(`${AIO_DIR}/ngsw-config.json`);
  const navigationUrlSpecs = processNavigationUrls('', config.navigationUrls);

  const includePatterns = navigationUrlSpecs
      .filter(spec => spec.positive)
      .map(spec => new RegExp(spec.regex));
  const excludePatterns = navigationUrlSpecs
      .filter(spec => !spec.positive)
      .map(spec => new RegExp(spec.regex));

  return (url: string) =>
    includePatterns.some(regex => regex.test(url))
    && !excludePatterns.some(regex => regex.test(url));
}
开发者ID:BobChao87,项目名称:angular,代码行数:15,代码来源:helpers.ts

示例6: loadSWRoutes

export function loadSWRoutes() {
  const pathToSWManifest = path.resolve(__dirname, '../../ngsw-manifest.json');
  const contents = cjson.load(pathToSWManifest);
  const routes = contents.routing.routes;
  return Object.keys(routes).map(route => {
    const routeConfig = routes[route];
    switch (routeConfig.match) {
      case 'exact':
        return (url) => url === route;
      case 'prefix':
        return (url) => url.startsWith(route);
      case 'regex':
        const regex = new RegExp(route);
        return (url) => regex.test(url);
      default:
        throw new Error(`unknown route config: ${route} - ${routeConfig.match}`);
    }
  });
}
开发者ID:cironunes,项目名称:angular,代码行数:19,代码来源:helpers.ts

示例7: loadRedirects

export function loadRedirects(): FirebaseRedirectConfig[] {
  const pathToFirebaseJSON = path.resolve(__dirname, '../../firebase.json');
  const contents = cjson.load(pathToFirebaseJSON);
  return contents.hosting.redirects;
}
开发者ID:cironunes,项目名称:angular,代码行数:5,代码来源:helpers.ts

示例8: loadRedirects

export function loadRedirects(): FirebaseRedirectConfig[] {
  const pathToFirebaseJSON = `${AIO_DIR}/firebase.json`;
  const contents = loadJson(pathToFirebaseJSON);
  return contents.hosting.redirects;
}
开发者ID:DallanQ,项目名称:rxjs,代码行数:5,代码来源:helpers.ts


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