Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (!args.bucket) {
args.bucket = process.env.COS_BUCKET
}
if (!args.region) {
args.region = process.env.COS_REGION
}
// Check the user's configuration
if (!checkHexoConfig(args)) {
log.error('hexo-deployer-cos: config error')
return
}
// Get local files list from Public Directory
let localFiles = fs.listDirSync(this.public_dir)
// Create COS object
let cos = new COS({
SecretId: args.secretId,
SecretKey: args.secretKey
})
// Bucket's configuration
const bucketConfig = {
Bucket: args.bucket,
Region: args.region
}
log.info('Uploading files to COS...')
return Promise.all(localFiles.map(file => {
return {
name: matches[1],
filename,
path: path.join(basePath, filename)
};
}
const rootPath = hexo.config.root || '/';
const prismLineNumbersPluginDir = dirResolve('prismjs/plugins/line-numbers');
const prismThemeDir = dirResolve('prismjs/themes');
const extraThemeDir = dirResolve('prism-themes/themes');
const prismMainFile = require.resolve('prismjs');
const standardThemes = fs.listDirSync(prismThemeDir)
.map(themeFileName => toThemeMap(prismThemeDir, themeFileName));
const extraThemes = fs.listDirSync(extraThemeDir)
.map(themeFileName => toThemeMap(extraThemeDir, themeFileName));
// Since the regex will not match for the default "prism.css" theme,
// we filter the null theme out and manually add the default theme to the array
const themes = standardThemes.concat(extraThemes).filter(Boolean);
themes.push({
name: 'default',
filename: 'prism.css',
path: path.join(prismThemeDir, 'prism.css')
});
// If prism plugin has not been configured, it cannot be initialized properly.
if (!hexo.config.prism_plugin) {
throw new Error('`prism_plugin` options should be added to _config.yml file');
}
if (!matches)
return;
return {
name: matches[1],
filename,
path: path.join(basePath, filename)
};
}
const rootPath = hexo.config.root || '/';
const prismLineNumbersPluginDir = dirResolve('prismjs/plugins/line-numbers');
const prismThemeDir = dirResolve('prismjs/themes');
const extraThemeDir = dirResolve('prism-themes/themes');
const prismMainFile = require.resolve('prismjs');
const standardThemes = fs.listDirSync(prismThemeDir)
.map(themeFileName => toThemeMap(prismThemeDir, themeFileName));
const extraThemes = fs.listDirSync(extraThemeDir)
.map(themeFileName => toThemeMap(extraThemeDir, themeFileName));
// Since the regex will not match for the default "prism.css" theme,
// we filter the null theme out and manually add the default theme to the array
const themes = standardThemes.concat(extraThemes).filter(Boolean);
themes.push({
name: 'default',
filename: 'prism.css',
path: path.join(prismThemeDir, 'prism.css')
});
// If prism plugin has not been configured, it cannot be initialized properly.
if (!hexo.config.prism_plugin) {
throw new Error('`prism_plugin` options should be added to _config.yml file');
function getFiles(dir, callback) {
fs.listDirSync(dir).forEach((filePath) => {
callback(filePath);
});
}
function traverseFiles(dir, handle) {
var files = fs.listDirSync(dir);
files.forEach(function (filePath) {
var absPath = pathFn.join(dir, filePath),
stat = fs.statSync(absPath);
if (stat.isDirectory()) {
traverseFiles(absPath, handle);
} else {
handle(absPath);
}
});
}