Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function ( current ){
var source = fs.readFileSync( current + 'config/assets.yml', 'utf8' );
var config = yaml.load( source );
var version_path = current + 'public/assets_version.json';
var tmp_dir = current + 'tmp/assets/';
lib.pub_dir = current + 'public/';
var flow = new Flow({
log : true,
minify : true,
uglify : false
});
// check if the dir exist, if it does remove it
flow.series( function ( args, next ){
if( !fs.existsSync( tmp_dir )) return next();
rmdir( tmp_dir, function ( err, dirs, files ){
if (await fs.exists(testpath)) {
filepath = testpath;
break;
}
}
}
let new_variants = this.loadVariantsFromSettings();
// Check once more that we have a file to read
if (filepath && await fs.exists(filepath)) {
const content = (await fs.readFile(filepath)).toString();
try {
if (filepath.endsWith('.json')) {
new_variants = json5.parse(content);
} else {
new_variants = yaml.load(content) as VarFileRoot;
}
} catch (e) { log.error(`Error parsing ${filepath}: ${e}`); }
}
const is_valid = validate(new_variants);
if (!is_valid) {
const errors = validate.errors as ajv.ErrorObject[];
log.error('Invalid variants specified:');
for (const err of errors) {
log.error(` >> ${err.dataPath}: ${err.message}`);
}
new_variants = DEFAULT_VARIANTS;
log.info('Loaded default variants');
} else {
log.info('Loaded new set of variants');
}
additions = '',
manifest = {}
;
var pageName = path.basename(file.path).match(/^script\.(.*)\.js$/)[1];
var pageFolder = path.resolve(path.dirname(file.path), '../');
if (pageName !== pageFolder.substr(pageFolder.lastIndexOf('/') + 1)) {
console.log('ERROR!!!!!!! wrongly named file!');
}
var originalPageFolder = path.resolve(pageFolder, '../../../src/pages/' + pageName);
var yamlFile = originalPageFolder + '/config.' + pageName + '.yml';
if (fs.existsSync(yamlFile)) {
manifest = yaml.load(fs.readFileSync(yamlFile)) || {};
}
if (!manifest.css) {
if (fs.existsSync(originalPageFolder + '/css/style.' + pageName + '.styl')) {
manifest.css = 'pages/' + pageName + '/css/style.' + pageName + '.css';
}
}
if (!manifest.html) {
var htmlFile = originalPageFolder + '/html/view.' + pageName + '.html';
if (fs.existsSync(htmlFile)) {
additions += 'module.exports.config.html = require(\'raw!' + htmlFile + '\');';
}
}
.map(function(basename) {
return yaml.load(String(fs.readFileSync(join(info.root, basename))))
})
.reduce(function(all, cur) {
return fs.readFile(lastEditPath, function(err, text) {
if (err == null) {
const data = YAML.load(text);
const {novel:{name}, chapter: {number}} = data.opened;
wl.novel.openNovel(name || "はじめよう");
(number != null) && wl.novel.openChapter(number);
return wl.editor.setDirection(data.status.direction);
} else { return wl.novel.openNovel("はじめよう"); }
});
}
loadRooms() {
let roomsYaml;
try {
roomsYaml = fs.readFileSync(path.join(this.basePath, 'rooms.yml'));
} catch (err) {
return new Error('Error loading Rooms yaml');
}
this.rooms = yaml.load(roomsYaml);
}
async() => {
if (cliArgs.current.length < 1) return
const argRaw = cliArgs.current[0]
let body
try {
body = load(argRaw)
} catch {
return
}
if (typeof body !== 'object' || body === null) return
cliArgs.current.splice(0, 1)
for (const field in body) {
//$todo
setConfig(field, body[field])
}
},
async() => {
this.readFile(e.target.files, (newResource: string) => {
const resource: T = jsYaml.load(newResource);
this.validate(resource);
formikApi.setFieldValue('resource', resource);
formikApi.setFieldValue('resourceString', jsYaml.dump(resource));
});
} catch (e) {
? options
: undefined;
let re = /^(-{3}(?:\n|\r)([\w\W]+?)(?:\n|\r)-{3})?([\w\W]*)*/
, results = re.exec(text)
, conf = {}
, yamlOrJson;
if ((yamlOrJson = results[2])) {
if (yamlOrJson.charAt(0) === '{') {
conf = JSON.parse(yamlOrJson);
} else {
if(loadSafe) {
conf = jsYaml.safeLoad(yamlOrJson, passThroughOptions);
} else {
conf = jsYaml.load(yamlOrJson, passThroughOptions);
}
}
}
conf[contentKeyName] = results[3] || '';
return conf;
};
const mergeYaml: FileGenerator = async file => {
let content = file.content
const beginMatched = content.match(/^\s*/g)
const beginBlank = beginMatched ? beginMatched[0] : ''
const endMatched = content.match(/\s*$/g)
const endBlank = endMatched ? endMatched[0] : ''
let result = content
if (!file.projectFileExisted) {
try {
content = yaml.load(file.content)
result = yaml.dump(content).replace(/\s*$/, '')
} catch (e) {
throw new Error([
'The template file and the project file failed to merge due to a json syntax error in the template file.',
'The project file will be overwritten directly by the template file.',
`path: ${file.templatePath}`,
].join('\n'))
}
} else {
let projectContent = await file.getProjectContent()
try {
content = yaml.load(file.content)
} catch (e) {
throw new Error([
'The template file and the project file failed to merge due to a json syntax error in the template file.',