Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return spawn('git', ['clone', fakeRemote, validateDir, '--branch', branch]).then(() => {
// Check the branch name
return fs.readFile(pathFn.join(validateDir, '.git', 'HEAD'));
}).then(content => {
content.trim().should.eql('ref: refs/heads/' + branch);
}).map(function (name) {
let path = pathFn.join(pluginDir, name);
let packagePath = pathFn.join(path, 'package.json');
// Read generator config.
return fs.readFile(packagePath).then(function (content) {
const json = JSON.parse(content);
const desc = json.description;
return {name, desc};
});
});
}
function getLocalFile (sidebar, href, source) {
// get the resolve path to the file
// cypress-101 -> guides/core-concepts/cypress-101.html
const pathToFile = findFileBySource(sidebar, href)
if (pathToFile) {
// ensure this physically exists on disk
// inside of './source' folder
return fs.readFile(
path.resolve('source', pathToFile.replace('.html', '.md'))
).then((str) => {
// return an array with
// path to file, and str bytes
return [pathToFile, str]
})
}
return Promise.reject(
new Error(`Constructing {% url %} tag helper failed
> The source file was: ${source}
> Could not find a valid doc file in the sidebar.yml for: ${href}
`)
)
it('generate', () => fs.writeFile(pathFn.join(hexo.source_dir, 'test.txt'), 'test').then(() => deploy({generate: true})).then(() => fs.readFile(pathFn.join(hexo.public_dir, 'test.txt'))).then(content => {
content.should.eql('test');
return Promise.map(assets, function(item){
return Promise.all([
fs.readFile(pathFn.join(assetDir, item === '.gitignore' ? 'gitignore' : item)),
fs.readFile(pathFn.join(baseDir, item))
]).spread(function(asset, target){
target.should.eql(asset);
});
}).then(function(){
return fs.rmdir(baseDir);
}).then(post => {
post.path.should.eql(path);
post.content.should.eql(content);
hexo.config.filename_case = 0;
return fs.readFile(path);
}).then(data => {
data.should.eql(content);
}).then(() => {
const extTxtFile = pathFn.join(validateDir, extendDirName, 'ext.txt');
return fs.readFile(extTxtFile);
}).then(content => {
content.should.eql('ext');
}).then(() => fs.readFile(path)).then(content => {
content.should.eql(body);
function checkPkg(path){
return fs.readFile(path).then(function(content){
var json = JSON.parse(content);
return typeof json.hexo === 'object';
});
}
return new Promise((resolve, reject) => {
if (!data) return reject(new TypeError('No input file or string!'));
if (data.text != null) return resolve(data.text);
if (!data.path) return reject(new TypeError('No input file or string!'));
fs.readFile(data.path).then(resolve, reject);
}).then(text => {
data.text = text;