本文整理匯總了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)
}