本文整理匯總了TypeScript中jsonfile.readFileSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript readFileSync函數的具體用法?TypeScript readFileSync怎麽用?TypeScript readFileSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了readFileSync函數的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
gulp.task('!manifest', function () {
const meta = util.currentPackage();
const copyInst = util.getCopyInstruction(meta);
const pkgDest = Path.join(copyInst.to, 'package.json');
const pkgJson = jsonfile.readFileSync(util.root('package.json'));
const localPackageJsonPath = util.root(util.FS_REF.SRC_CONTAINER, meta.dir, 'package.json');
if (fs.existsSync(localPackageJsonPath)) {
Object.assign(
pkgJson,
jsonfile.readFileSync(localPackageJsonPath)
)
}
PKGJSON_KEYS_TO_DELETE.forEach( k => { delete pkgJson[k] });
pkgJson.name = meta.dir;
pkgJson.main = `${util.FS_REF.BUNDLE_DIR}/${meta.umd}.rollup.umd.js`;
pkgJson.module = `${util.FS_REF.BUNDLE_DIR}/${meta.umd}.es5.js`;
pkgJson.es2015 = `${util.FS_REF.BUNDLE_DIR}/${meta.umd}.js`;
pkgJson.typings = `${util.FS_REF.SRC_CONTAINER}/${util.getMainOutputFileName(meta)}.d.ts`;
util.tryRunHook(meta.dir, 'packageJSON', pkgJson);
jsonfile.writeFileSync(pkgDest, pkgJson, {spaces: 2});
});
示例2: getSettings
export function getSettings():Isettings{
//Give some default values
let settings:Isettings = {
port : getRandomPort()
};
// *******************************************
// Checks that iisexpress.json exist
// *******************************************
let settingsFilePath = vscode.workspace.rootPath + "\\.vscode\\iisexpress.json";
//use -> https://www.npmjs.com/package/jsonfile
var jsonfile = require('jsonfile');
try {
//Check if we can find the file path (get stat info on it)
let fileCheck = fs.statSync(settingsFilePath);
//read file .vscode\iisexpress.json and overwrite port property from iisexpress.json
settings = jsonfile.readFileSync(settingsFilePath);
}
catch (err) {
//file didn't exist so
//create .vscode\iisexpress.json and append settings object
jsonfile.writeFile(settingsFilePath, settings, {spaces: 2}, function (err) {
console.error(err);
});
}
//Return an object back from verifications
return settings;
}
示例3: file
@util.GulpClass.Task({
name: 'misc:syncConfig',
desc: `Sync the main tsconfig file (tsconfig.json) and JEST configuration file with paths information.
This is required after each change to a package configuration that results in a file structure change.
This includes adding, removing or changing a package name. Changing the top-level scope, etc..`
})
syncConfig() {
const tsConfig = jsonfile.readFileSync(util.root('tsconfig.json'));
tsConfig.compilerOptions.paths = util.tsConfigPaths();
util.tryRunHook('./', 'tsconfig', tsConfig);
jsonfile.writeFileSync(util.root('tsconfig.json'), tsConfig, {spaces: 2});
const jestConfig = jsonfile.readFileSync(util.root('jest.library.config.json'));
jestConfig.moduleNameMapper = util.jestAlias();
util.tryRunHook('./', 'jestConfig', jestConfig);
jsonfile.writeFileSync(util.root('jest.library.config.json'), jestConfig, {spaces: 2});
}
示例4: decrypt
function decrypt() {
file = "data.json";
var objRead = jsonfile.readFileSync(file); //JSON Object containing credentials
encryptedUsername = objRead.username;
encryptedPassword = objRead.password;
}
示例5: Promise
.then( () => {
const p = util.root(util.currentPackage().tsConfigObj.compilerOptions.outDir);
del.sync(p);
const tsConfig = jsonfile.readFileSync(util.root(util.FS_REF.TS_CONFIG_TMP));
tsConfig.compilerOptions.target = 'es5';
jsonfile.writeFileSync(util.root(util.FS_REF.TS_CONFIG_TMP), tsConfig, {spaces: 2});
return new Promise( (resolve, reject) => webpack(config).run((err, stats) => err ? reject(err) : resolve(stats)) );
})
示例6: join
fs.readdirSync(current).forEach(function (file) {
if (file === 'meta.json') {
file = join('.', sep, current, file);
let currentChapterAbr = file.match(/(ch\d+)/)[0];
let chapter = CHAPTERS_MAP[currentChapterAbr];
result.push({
chapter,
file: current,
meta: jsonfile.readFileSync(file)
});
} else if (fs.lstatSync(join(current, file)).isDirectory()) {
result = result.concat(readMetadata(join(current, file), appRoot));
}
});
示例7: update
export function jsonPatch<T>(readPath: string): { update: (handler: (data: T) => (T | null | void)) => { save: (savePath: string) => void } } {
return {
update(handler: (data: T) => T): any {
const tsconfig = jsonfile.readFileSync(readPath);
const data = handler(tsconfig);
return {
save(savePath: string): void {
if (data !== null) {
jsonfile.writeFileSync(savePath, data || tsconfig, {spaces: 2});
}
}
};
}
};
}
示例8: getConfigurationData
public getConfigurationData(configurationFileName: string): any {
var self = this;
var terminal = this.terminal;
var configurationData: any = null;
// Read the main resource configuration file from disk.
terminal.echoInfo("Reading configuration filename \"" + configurationFileName + "\"");
try {
configurationData = jsonFile.readFileSync(configurationFileName, { throws: true });
}
catch (exception) {
terminal.echoScreamingError("Error parsing configuration file, " + exception.toString());
process.exit(1);
}
return configurationData;
}
示例9: if
dialog.showOpenDialog(dialogOptions, filename => {
if (
args.action === "CertPath" ||
args.action === "KeyPath" ||
args.action === "AssetPath"
) {
event.sender.send("open", {
action: args.action,
path: filename
});
} else if (args.action === "OpenProject") {
if (filename) {
event.sender.send("open", {
action: args.action,
path: filename,
content: jsonfile.readFileSync(filename[0])
});
}
}
});