Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('write multiconfig to specified path', () => {
const outputPath = osFn.tmpdir();
const combinedPath = pathFn.join(outputPath, '_multiconfig.yml');
mcp(base, 'test1.yml', outputPath).should.not.eql(combinedPath);
mcp(base, 'test1.yml,test2.yml', outputPath).should.eql(combinedPath);
mcp(base, 'test1.yml,test1.json', outputPath).should.eql(combinedPath);
mcp(base, 'test1.json,test2.json', outputPath).should.eql(combinedPath);
mcp(base, 'notafile.yml,test1.json', outputPath).should.eql(combinedPath);
mcp(base, 'notafile.yml,alsonotafile.json', outputPath).should.not.eql(combinedPath);
// delete /tmp/_multiconfig.yml
fs.unlinkSync(combinedPath);
hexo.log.reader[1].type.should.eql('debug');
hexo.log.reader[1].msg.should.eql(`Writing _multiconfig.yml to ${combinedPath}`);
hexo.log.reader[2].type.should.eql('info');
hexo.log.reader[2].msg.should.eql('Config based on 2 files');
hexo.log.reader[6].type.should.eql('warning');
hexo.log.reader[6].msg.should.eql('Config file notafile.yml not found.');
hexo.log.reader[7].type.should.eql('info');
hexo.log.reader[7].msg.should.eql('Config based on 1 files');
hexo.log.reader[11].type.should.eql('error');
hexo.log.reader[11].msg.should.eql('No config files found.'
+ ' Using _config.yml.');
});
});
fs.writeFile(full_source, raw, function(err){
if (err) return callback(err);
if (full_source !== prev_full) {
fs.unlinkSync(prev_full)
// move asset dir
var assetPrev = removeExtname(prev_full);
var assetDest = removeExtname(full_source);
fs.exists(assetPrev).then(function(exist) {
if (exist) {
fs.copyDir(assetPrev, assetDest).then(function() {
fs.rmdir(assetPrev);
});
}
});
}
hexo.source.process([post.source]).then(function () {
// console.log(post.full_source, post.source)
callback(null, hexo.model(model).get(id));
});
});
const { log, baseDir, pluginDir, logDir } = this;
const packagePath = pathFn.join(baseDir, 'package.json');
const packageLockPath = pathFn.join(baseDir, 'package-lock.json');
// Remove plugin dir
if (fs.existsSync(pluginDir) && fs.lstatSync(pluginDir).isDirectory()) {
deleteFolderRecursive(pluginDir);
}
// Remove log dir
if (fs.existsSync(logDir) && fs.lstatSync(logDir).isDirectory()) {
deleteFolderRecursive(logDir);
}
// Remove package-lock.json
fs.unlinkSync(packageLockPath);
// Rewrite package.json
fs.writeFileSync(packagePath, JSON.stringify({
'name': 'feflow-home',
'version': '0.0.0',
'private': true
}, null, 4));
log.info('Feflow 重新重新初始化完成');
};
it('initClient has all', () => {
feflow.baseDir = path.resolve(__dirname, './feflow-container/container/package.json');
feflow.config = {
registry: 'http://registry.npmjs.org'
};
initClient(feflow);
fs.rmdirSync(feflow.logDir);
fs.unlinkSync(feflow.pkgPath);
fs.unlinkSync(feflow.rcPath);
});
})
after(() => {
fs.rmdirSync(hexo.base_dir);
fs.unlinkSync('/tmp/test3.json');
});
.then(_ => {
fs.unlinkSync(feflow.rcPath);
});
});
afterEach(() => {
this.sandbox.restore();
if (fs.existsSync(testPath)) {
fs.unlinkSync(testPath);
}
});
fs.readdirSync(path).forEach(function (file) {
const curPath = path + '/' + file;
if (fs.lstatSync(curPath).isDirectory()) {
deleteFolderRecursive(curPath);
} else {
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
return new Promise(function (resolve) {
if (fs.existsSync(baseDir) && fs.statSync(baseDir).isFile()) {
fs.unlinkSync(baseDir);
}
if (!fs.existsSync(baseDir)) {
log.info('检测到这是您第一次使用feflow,即将进行cli client初始化');
fs.ensurePathSync(baseDir);
}
log.debug('.feflow 目录已经创建');
resolve(ctx);
});
}