本文整理汇总了TypeScript中fs-extra.readJsonSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readJsonSync函数的具体用法?TypeScript readJsonSync怎么用?TypeScript readJsonSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readJsonSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getCustomConfig
/**
* 获取自定义配置
*/
function getCustomConfig (cwd: string = systemConfig.cwd): { [key: string]: CustomConfig } {
const pkgPath = getProjectPackagePath(cwd)
const filePath = getCustomConfigFilePath(cwd)
let customConfigFromPkg: CustomConfig = {} // for package.json
let customConfigFromFile: CustomConfig = {} // for min.config.json
// in package.json
if (fs.existsSync(pkgPath)) {
customConfigFromPkg = _.pick(fs.readJsonSync(pkgPath)['minConfig'] || {}, CUSTOM_CONFIG_MEMBER) as CustomConfig
}
// in min.config.json
if (fs.existsSync(filePath)) {
customConfigFromFile = _.pick(fs.readJsonSync(filePath), CUSTOM_CONFIG_MEMBER) as CustomConfig
}
// merge customConfigFromPkg and customConfigFromFile
let customConfig = _.merge({}, customConfigFromPkg, customConfigFromFile)
return {
customConfig,
customConfigFromPkg,
customConfigFromFile
}
}
开发者ID:bbxyard,项目名称:bbxyard,代码行数:29,代码来源:config.ts
示例2: uninstall
/**
* uninstall the module package
* @param module_name
* @param callback
*/
uninstall(module_name: string, callback: Function) {
var modules_file = fs.readJsonSync(modules_configuration_path);
if (modules_file[module_name] !== undefined) {
for (var i = 0; i < modules_file[module_name].routes.length; i++) {
try {
fs.unlinkSync(serverRoot + "\\routes\\" + modules_file[module_name].routes[i].path);
} catch (e) { }
}
deleteFolderRecursive(global.clientAppRoot + "\\modules\\" + module_name);
delete modules_file[module_name];
}
fs.writeFileSync(modules_configuration_path, JSON.stringify(modules_file));
try {
var manifest_file = fs.readJsonSync(global.clientAppRoot + "\\modules\\" + module_name + "\\" + consts.MANIFEST_NAME, { throws: false });
//merge the manifest into the modules.json file
if (manifest_file === null)
callback("invalid json, try using ascii file");
dal.connect(function (err: any, db: any) {
if (manifest_file.navigation) {
for (var i = 0; i < manifest_file.navigation.length; i++) {
db.collection("Navigation").remove({ "_id": manifest_file.navigation[i]._id }, function (err: any, data: any) {
});
}
}
})
//delete module folder
this.deleteFolderRecursive(global.clientAppRoot+ "\\modules\\" + module_name + "\\");
callback("ok");
}
catch (e) {
callback("ok");
}
}
开发者ID:gitter-badger,项目名称:nodulus,代码行数:63,代码来源:modules.ts
示例3: commit
export function commit(message: string, options: any) {
if (!!options.quiet) log.silence();
let repo = cwdRepo();
let allowEmpty = !!options.allowEmpty;
if (repo.staged.length < 1 && !allowEmpty) {
log.info('no changes to commit');
return;
}
let authorName: string = conf.get('authorName');
let authorEMail: string = conf.get('authorEMail');
var noAuthor = !authorName || !authorEMail;
if (noAuthor) {
log.error('either author name or email is not specified!');
return;
}
if (!repo.currentBranchName) {
log.error('you can not commit in detached HEAD state. Create new branch.');
return;
}
let optionConfig: string = options.reeditMessage || options.reuseMessage;
let amend = !!options.amend;
var oldCommitData: string[] = null;
var basedOnSomeCommit = false;
if (!!optionConfig) {
let lcOption = optionConfig.toLowerCase();
if (lcOption === "orig_head") {
oldCommitData = fse.readJsonSync(path.join(repo.root, '.jerk', 'ORIG_HEAD'));
basedOnSomeCommit = true;
} else if (lcOption === "head") {
oldCommitData = fse.readJsonSync(path.join(repo.root, '.jerk', 'HEAD'));
basedOnSomeCommit = true;
} else {
let branch = repo.ref<Common.Ref>(optionConfig);
if (!!branch) {
let cm = repo.commit(branch.head);
if (!!cm) {
oldCommitData = cm.data();
basedOnSomeCommit = true;
}
} else {
let cm = repo.commit(optionConfig);
if (!!cm) {
oldCommitData = cm.data();
basedOnSomeCommit = true;
}
}
}
}
var commit = repo.head.commit;
var newCommit = repo.createCommit(commit, message, authorName, authorEMail, amend, oldCommitData);
log.success(Format.formatCommitMessage(newCommit, '%Cyellow%h%Creset: %s'));
}
开发者ID:STALKER2010,项目名称:jerk,代码行数:58,代码来源:cli.ts
示例4: forEach
forEach(tasks.getTasks(), (task) => {
const targetNodeCommonDir = path.join(task.directory, "common");
const taskNodeModules = path.join(task.directory, "node_modules");
const targetPowershellCommonDir = path.join(task.directory, "ps_modules");
const taskFilePath = path.join(task.directory, "task.json");
const taskFile = fs.existsSync(taskFilePath) ? fs.readJsonSync(taskFilePath) : {};
if (taskFile.execution.Node) {
fs.ensureDirSync(targetNodeCommonDir);
fs.ensureDirSync(taskNodeModules);
forEach(nodeFiles, (commonFile) => {
const targetFile = path.join(targetNodeCommonDir, commonFile);
console.log(targetFile);
fs.copySync(path.join(nodeCommonFilesRoot, commonFile), targetFile, { overwrite: true });
});
}
if (taskFile.execution.PowerShell3) {
fs.ensureDirSync(targetPowershellCommonDir);
forEach(powershellFiles, (commonFile) => {
const targetFile = path.join(targetPowershellCommonDir, commonFile);
console.log(targetFile);
fs.copySync(path.join(powershellCommonFilesRoot, commonFile), targetFile, { overwrite: true });
});
}
});
开发者ID:geeklearningio,项目名称:gl-vsts-tasks-build-scripts,代码行数:27,代码来源:prebuild.ts
示例5: _processMock
/**
* Processes all the mocks that are present in the given directory.
* @param {string} directory The directory containing the mocks.
* @returns {Mock[]} mocks The mocks.
*/
function _processMock(file: string): void {
try {
const mock: Mock = fs.readJsonSync(file);
utils.updateMock(mock);
} catch (ex) {
console.info(file, 'contains invalid json');
}
}
开发者ID:mdasberg,项目名称:ng-apimock,代码行数:13,代码来源:index.ts
示例6: getLastCommit
.reduce( (versionCache, dirName) => {
const version = fs.readJsonSync(getPackageRoot(dirName, 'package.json')).version;
versionCache[dirName] = {
commit: getLastCommit(dirName),
version
};
return versionCache;
}, {});
开发者ID:shlomiassaf,项目名称:ng2-chess,代码行数:8,代码来源:release_mgmt.ts
示例7: getAppScriptsPackageJson
export function getAppScriptsPackageJson() {
if (!cachedAppScriptsPackageJson) {
try {
cachedAppScriptsPackageJson = readJsonSync(join(__dirname, '..', '..', 'package.json'));
} catch (e) {}
}
return cachedAppScriptsPackageJson;
}
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:8,代码来源:helpers.ts
示例8: getJSON
getJSON(): any {
const configPath = path.resolve(process.env.PWD, 'ng2-cli.json');
if (helper.existsSync(configPath)) {
return fse.readJsonSync(configPath);
} else {
throw new Error('Config file not found.');
}
}
开发者ID:jkuri,项目名称:ng2-cli,代码行数:8,代码来源:config.ts
示例9: Error
files.forEach(file => {
const def = fs.readJsonSync(file);
def.file = file;
const title = getTitle(def);
if (defs[title]) {
throw new Error('Duplicate entry ' + title);
}
defs[title] = def;
});
开发者ID:eclipsesource,项目名称:tabris-js,代码行数:9,代码来源:common.ts
示例10: processFile
async function processFile ({ filePath, tempPath, entryBaseName }) {
const indexJsStr = `
import {AppRegistry} from 'react-native';
import App from '../${entryBaseName}';
// import {name as appName} from '../app.json';
AppRegistry.registerComponent('${moduleName}', () => App);`
if (!fs.existsSync(filePath)) {
return
}
const dirname = path.dirname(filePath)
const destDirname = dirname.replace(tempPath, jdreactPath)
const destFilePath = path.format({dir: destDirname, base: path.basename(filePath)})
const indexFilePath = path.join(tempPath, 'index.js')
const tempPkgPath = path.join(tempPath, 'package.json')
// generate jsbundles/moduleName.js
if (filePath === indexFilePath) {
const indexDistDirPath = path.join(jdreactPath, 'jsbundles')
const indexDistFilePath = path.join(indexDistDirPath, `${moduleName}.js`)
fs.ensureDirSync(indexDistDirPath)
fs.writeFileSync(indexDistFilePath, indexJsStr)
Util.printLog(processTypeEnum.GENERATE, `${moduleName}.js`, indexDistFilePath)
return
}
// genetate package.json
if (filePath === tempPkgPath) {
const destPkgPath = path.join(jdreactPath, 'package.json')
const templatePkgPath = path.join(jdreactTmpDirname, 'pkg')
const tempPkgObject = fs.readJsonSync(tempPkgPath)
const templatePkgObject = fs.readJsonSync(templatePkgPath)
templatePkgObject.name = `jdreact-jsbundle-${moduleName}`
templatePkgObject.dependencies = Object.assign({}, tempPkgObject.dependencies, templatePkgObject.dependencies)
fs.writeJsonSync(destPkgPath, templatePkgObject, {spaces: 2})
Util.printLog(processTypeEnum.GENERATE, 'package.json', destPkgPath)
return
}
fs.ensureDirSync(destDirname)
fs.copySync(filePath, destFilePath)
Util.printLog(processTypeEnum.COPY, _.camelCase(path.extname(filePath)).toUpperCase(), filePath)
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:44,代码来源:convert_to_jdreact.ts
注:本文中的fs-extra.readJsonSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论