本文整理汇总了TypeScript中fs-extra.writeJSONSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript writeJSONSync函数的具体用法?TypeScript writeJSONSync怎么用?TypeScript writeJSONSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeJSONSync函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: printLog
creator.fs.commit(() => {
const pkgObj = JSON.parse(fs.readFileSync(pkgPath).toString())
pkgObj.dependencies['@tarojs/with-weapp'] = `^${version}`
fs.writeJSONSync(pkgPath, pkgObj, {
spaces: 2,
EOL: '\n'
})
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(configDir, 'index.js')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(configDir, 'dev.js')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(configDir, 'prod.js')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(pkgPath))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(this.convertRoot, 'project.config.json')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(this.convertRoot, '.gitignore')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(this.convertRoot, '.editorconfig')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(this.convertRoot, '.eslintrc')))
printLog(processTypeEnum.GENERATE, '文件', this.generateShowPath(path.join(this.convertDir, 'index.html')))
})
示例2: it
it("updates tokens", function (done) {
const user = {
id: "api_testuser",
token: "original-token",
url: "https://api.sbgenomics.com",
user: {username: "testuser"}
};
const initialData = {
credentials: [user],
activeCredentials: user
};
const repository = new DataRepository(dir.name);
const localProfilePath = repository.getProfileFilePath("local");
fs.writeJSONSync(localProfilePath, initialData);
repository.load(() => {
const patch = {
credentials: [
{...user, token: "updated-token"}
]
};
repository.updateLocal(patch, (err) => {
if (err) {
return done(err);
}
setTimeout(() => {
const profile = fs.readJSONSync(localProfilePath);
assert.deepEqual(profile.credentials, patch.credentials);
done();
}, 100);
});
});
});
示例3:
});
fs.writeJSON(file, object).then(() => {
// stub
});
fs.writeJson(file, object, errorCallback);
fs.writeJson(file, object, writeOptions, errorCallback);
fs.writeJSON(file, object, errorCallback);
fs.writeJSON(file, object, writeOptions, errorCallback);
fs.writeJson(file, object, writeOptions).then(() => {
// stub
});
fs.writeJSON(file, object, writeOptions).then(() => {
// stub
});
fs.writeJsonSync(file, object, writeOptions);
fs.writeJSONSync(file, object, writeOptions);
fs.ensureDir(path).then(() => {
// stub
});
fs.ensureDir(path, errorCallback);
fs.ensureDirSync(path);
fs.ensureFile(path).then(() => {
// stub
});
fs.ensureFile(path, errorCallback);
fs.ensureFileSync(path);
fs.ensureLink(path).then(() => {
// stub
});
示例4: compilePluginJson
function compilePluginJson (pluginJson, pluginPath) {
if (typeof pluginJson.main === 'string') {
pluginJson.main = pluginJson.main.replace(/.tsx$/, '.js')
}
fs.writeJSONSync(pluginPath, pluginJson)
}