本文整理汇总了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;未经允许,请勿转载。 |
请发表评论