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


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

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


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

示例1: getInstalledNpmPkgVersion

export function getInstalledNpmPkgVersion (pkgName: string, basedir: string): string | null {
  const pkgPath = getInstalledNpmPkgPath(pkgName, basedir)
  if (!pkgPath) {
    return null
  }
  return fs.readJSONSync(pkgPath).version
}
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:7,代碼來源:index.ts

示例2: setTimeout

                setTimeout(() => {
                    const profile = fs.readJSONSync(localProfilePath);

                    assert.deepEqual(profile.credentials, patch.credentials);

                    done();
                }, 100);
開發者ID:hmenager,項目名稱:composer,代碼行數:7,代碼來源:data-repository.spec.ts

示例3: getAppPackageJsonData

function getAppPackageJsonData(context: BuildContext) {
  if (!appPackageJsonData) {
    try {
      appPackageJsonData = readJSONSync(join(context.rootDir, 'package.json'));
    } catch (e) {}
  }

  return appPackageJsonData;
}
開發者ID:Kode-Kitchen,項目名稱:ionic-app-scripts,代碼行數:9,代碼來源:config.ts

示例4: generateQuickAppManifest

function generateQuickAppManifest () {
  const { appConfig, pageConfigs, appPath, outputDir, projectConfig } = getBuildData()
  // 生成 router
  const pages = (appConfig.pages as string[]).concat()
  const routerPages = {}
  pages.forEach(element => {
    routerPages[path.dirname(element)] = {
      component: path.basename(element),
      filter: {
        view: {
          uri: 'https?://.*'
        }
      }
    }
  })
  const routerEntry = pages.shift()
  const router = {
    entry: path.dirname(routerEntry as string),
    pages: routerPages
  }
  // 生成 display
  const display = JSON.parse(JSON.stringify(appConfig.window || {}))
  display.pages = {}
  pageConfigs.forEach((item, page) => {
    if (item) {
      display.pages[path.dirname(page)] = item
    }
  })
  // 讀取 project.quickapp.json
  const quickappJSONPath = path.join(appPath, 'project.quickapp.json')
  let quickappJSON
  if (fs.existsSync(quickappJSONPath)) {
    quickappJSON = fs.readJSONSync(quickappJSONPath)
  } else {
    quickappJSON = fs.readJSONSync('../config/manifest.default.json')
  }
  quickappJSON.router = router
  quickappJSON.display = display
  quickappJSON.config = Object.assign({}, quickappJSON.config, {
    designWidth: projectConfig.designWidth || 750
  })
  fs.writeFileSync(path.join(outputDir, 'manifest.json'), JSON.stringify(quickappJSON, null, 2))
}
開發者ID:YangShaoQun,項目名稱:taro,代碼行數:43,代碼來源:index.ts

示例5: readFromFile

 readFromFile(): any {
   this.debug(`Reading config file "${this.configFile}"...`);
   try {
     return fs.readJSONSync(this.configFile);
   } catch (error) {
     const schemataKeys = Object.keys(SchemaUpdater.SCHEMATA);
     // In case of an error, always use the latest schema with sensible defaults:
     return SchemaUpdater.SCHEMATA[schemataKeys[schemataKeys.length - 1]];
   }
 }
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:10,代碼來源:ConfigurationPersistence.ts

示例6: loadSwaggerDocument

 private static loadSwaggerDocument(options: SwaggerOptions) {
     let swaggerDocument: any;
     if (_.endsWith(options.filePath, '.yml') || _.endsWith(options.filePath, '.yaml')) {
         swaggerDocument = YAML.load(options.filePath);
     }
     else {
         swaggerDocument = fs.readJSONSync(options.filePath);
     }
     return swaggerDocument;
 }
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:10,代碼來源:server.ts

示例7: done

            repository.updateLocal(update, (err) => {
                if (err) {
                    return done(err);
                }

                const profileFilePath = repository.getProfileFilePath("local");
                const profile         = fs.readJSONSync(profileFilePath);

                assert.deepEqual(profile.credentials, update.credentials);
                assert.deepEqual(profile.activeCredentials, update.activeCredentials)

                done();
            });
開發者ID:hmenager,項目名稱:composer,代碼行數:13,代碼來源:data-repository.spec.ts

示例8: configure

 public static configure() {
     try {
         const CONFIG_FILE = this.searchConfigFile();
         if (CONFIG_FILE && fs.existsSync(CONFIG_FILE)) {
             const config = fs.readJSONSync(CONFIG_FILE);
             if (config.useIoC) {
                 Server.useIoC(config.es6);
             } else if (config.serviceFactory) {
                 if (config.serviceFactory.indexOf('.') === 0) {
                     config.serviceFactory = path.join(process.cwd(), config.serviceFactory);
                 }
                 Server.registerServiceFactory(config.serviceFactory);
             }
         }
     } catch (e) {
         // tslint:disable-next-line:no-console
         console.error(e);
     }
 }
開發者ID:thiagobustamante,項目名稱:typescript-rest,代碼行數:19,代碼來源:config.ts

示例9: writePackageJson

/**
 * For a given repo, generate a new package.json and write it to disk.
 */
async function writePackageJson(
    repo: WorkspaceRepo,
    options: {version: string, flat: boolean, private: boolean}) {
  const bowerPackageName = path.basename(repo.dir);
  const bowerJsonPath = path.join(repo.dir, 'bower.json');
  const bowerJson = fse.readJSONSync(bowerJsonPath) as Partial<BowerConfig>;
  const npmPackageName =
      lookupNpmPackageName(bowerJsonPath) || bowerPackageName;

  const packageJsonPath = path.join(repo.dir, 'package.json');
  const existingPackageJson =
      await readJsonIfExists<Partial<YarnConfig>>(packageJsonPath);

  const packageJson = generatePackageJson(
      bowerJson,
      {name: npmPackageName, ...options},
      undefined,
      existingPackageJson);
  writeJson(packageJson, packageJsonPath);
}
開發者ID:,項目名稱:,代碼行數:23,代碼來源:

示例10: lookupNpmPackageName

export function lookupNpmPackageName(bowerJsonPath: string): string|undefined {
  let bowerPackageName: string;
  // Lookup the official package name via `bower.json`.
  try {
    const bowerJson = fse.readJSONSync(bowerJsonPath);
    bowerPackageName = bowerJson.name as string;
  } catch (err) {
    console.warn(
        `WARNING: "${bowerJsonPath}" not found / could not be read` +
        `(${err.message})`);
    return;
  }
  // Check our dependency map for the corresponding package name on npm.
  const depInfo = lookupDependencyMapping(bowerPackageName);
  if (!depInfo) {
    return bowerPackageName;
  }
  // If lookup was successful, return the correct npm package name.
  return depInfo.npm;
}
開發者ID:,項目名稱:,代碼行數:20,代碼來源:


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