Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
settings = getSettings()
// create options section if it doesn't exist, ie. first time changing settings
if (!settings.options) {
settings.options = {}
}
settings.options[name] = value
var addedOptions = addedOptsExist ? req.body.addedOptions : 'no additional options'
if (addedOptsExist) {
settings = deepAssign(settings, addedOptions)
}
hexo.log.d('set', name, '=', value, 'with', JSON.stringify(addedOptions))
fs.writeFileSync(hexo.base_dir + '_admin-config.yml', yml.safeDump(settings))
res.done({
updated: 'Successfully updated ' + name + ' = ' + value,
settings: settings
})
});
it('parseYaml() - path exists but no content', () => {
if (fs.existsSync(testPath)) {
fs.unlinkSync(testPath);
}
fs.writeFileSync(testPath, '', 'utf-8')
expect(yaml.parseYaml(testPath)).to.be.equal(undefined);
});
before(() => {
fs.writeFileSync(base + 'test1.yml', testYaml1);
fs.writeFileSync(base + 'test2.yml', testYaml2);
fs.writeFileSync(base + 'test1.json', testJson1);
fs.writeFileSync(base + 'test2.json', testJson2);
fs.writeFileSync('/tmp/test3.json', testJson3);
});
before(() => {
fs.writeFileSync(base + 'test1.yml', testYaml1);
fs.writeFileSync(base + 'test2.yml', testYaml2);
fs.writeFileSync(base + 'test1.json', testJson1);
fs.writeFileSync(base + 'test2.json', testJson2);
fs.writeFileSync('/tmp/test3.json', testJson3);
});
save() {
let path = this.post_dir + this.file;
let source = this.getTitle() + this.getDate() + this.getTags() +
this.getContent();
fs.writeFileSync(path, source, ['utf8', '438', 'w']);
console.log('This item ' + this.file + ' was saved!');
}
modifyDepsVersion(packagePath, arr) {
const obj = require(packagePath);
arr.map((item) => {
obj.dependencies[item.plugin] = item.ltsVersion;
});
fs.writeFileSync(packagePath, JSON.stringify(obj, null, 4));
}
return new Promise(function (resolve) {
if (!fs.existsSync(pkgPath)) {
fs.writeFileSync(pkgPath, JSON.stringify({
"name": "feflow-home",
"version": "0.0.0",
"private": true
}, null, 4));
}
log.debug('.feflow/package.json 文件已经创建');
resolve(ctx);
});
}
modifyDepsVersion(packagePath, arr) {
const obj = require(packagePath);
arr.map((item) => {
obj.dependencies[item.plugin] = item.ltsVersion;
});
fs.writeFileSync(packagePath, JSON.stringify(obj, null, 4));
}
modifyDepsVersion(packagePath, arr) {
const obj = require(packagePath);
arr.map((item) => {
obj.dependencies[item.plugin] = item.ltsVersion;
});
fs.writeFileSync(packagePath, JSON.stringify(obj, null, 4));
}