Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
glob(`${vueCompDir}/${vueCompName}*.md`, (mdFileErr, mdFiles) => {
if (mdFileErr)
throw new Error(`Error while trying to find markdown documentation files in directory ${vueCompDir}:\n${mdFileErr}`)
// no markdown documentation file exists yet, create one
if (mdFiles.length == 0) {
fs.outputFile(`${vueCompDir}/${vueCompName}-${currentVer}.md`, mdTemplate)
.then(() => console.log(`No existing markdown file for ${vueCompName}. Creating one at ${vueCompDir}/${vueCompName}-${currentVer}.md`))
.catch((createErr) => {
if (createErr)
throw new Error(`Error while trying to create markdown documentation file ${vueCompDir}/${vueCompName}-${currentVer}.md:\n${createErr}`)
})
}
else {
// find the most recent markdown documentation file based on NPM version
mdFiles.forEach((mdFile) => {
const starMdVer = mdFile.lastIndexOf(`${vueCompName}-`) + vueCompName.length + 1, endMdVer = mdFile.lastIndexOf('.')
const mdFileVer = mdFile.slice(starMdVer, endMdVer)
if (semver.valid(mdFileVer) && semver.lt(latestMdVer, mdFileVer)) {
latestMdVer = mdFileVer
latestMdDoc = mdFile
}
iconName: string,
svgIconFile: string,
fontIconFile: string
): Promise {
const svg = await fs.readFile(path.join(process.cwd(), svgFilePath), "utf8");
const contents = svg
.substring(SVG_ICON_PREFIX.length, svg.length - SVG_ICON_SUFFIX.length)
.replace(/fill-opacity/g, "fillOpacity")
// remove fill so the colors can be overridden in css
.replace(/ ?fill="#[A-Fa-f0-9]{3,6}"/g, "");
// eslint-disable-next-line no-console
console.log(contents.match(/fill/));
await Promise.all([
fs.outputFile(svgIconFile, createIconFile(componentName, contents, "SVG")),
fs.outputFile(
fontIconFile,
createIconFile(componentName, iconName, "Font")
),
]);
}
write_file: ['details', (results, callback) => {
if (_.isNil(_.get(results.details, 'scripts.install', null))) {
// No script defined, skip the rest.
const error = new Error('No installation script was defined for this egg, skipping rest of process.');
error.code = 'E_NOSCRIPT';
return callback(error);
}
this.server.log.debug('Writing temporary file to be handed into the Docker container.');
Fs.outputFile(Path.join('/tmp/pterodactyl/', this.server.json.uuid, '/install.sh'), results.details.scripts.install, {
mode: 0o644,
encoding: 'utf8',
}, callback);
}],
image: ['write_file', (results, callback) => {
}
// merge dirs and files according the modules
success('Apply install changes')
await exec('git add .', false)
success('Commit current project sources')
await exec('git commit -m "Project snapshot"', false)
success('Generate the patch between the 2 versions')
const diffOutput = await exec(`git diff --binary --no-color ${originBranch} ${branch}`, verbose)
success('Save the patch in tmp directory')
patchPath =
path.resolve(os.tmpdir(), `upgrade_${originBranch}_${branch}.patch`)
await fse.outputFile(patchPath, diffOutput)
await exec(`git checkout ${originBranch}`)
try {
success('Apply the patch')
await exec(`git apply --3way ${patchPath}`, verbose)
} catch (err) {
warn(
'The upgrade process succeeded but there might be conflicts to be resolved. ' +
'See above for the list of files that have merge conflicts.')
} finally {
success('Upgrade done')
}
} catch (err) {
await exec(`git checkout ${originBranch}`)
if (~err.message.indexOf('exited with')) {
dateStamp: dateStamp,
created: created,
updated: updated,
tags: tags,
metadata: metadata,
// Clean up the contents of the <content>
// tag. Evernote has quite a lot of cruft.
// Then convert into Markdown!
content: to_markdown(html)
};
post = insert_metadata(post);
fs.outputFile(post.path, post.content, function(err){
if (err) return callback(err);
next();
});
});
// When all the notes have been processed,</content>
for (let key in this.index) {
let filename = path.join(path.dirname(basePath), path.basename(basePath, ".lg") + (key ? `-${key}` : "") + ".lg");
let fileFlat = flat;
if (await fs.pathExists(filename)) {
log(`Merging existing ${filename}`);
let old = new LGTracker(this.schema);
let oldFile = await old.addLGFile(filename);
if (fileFlat === undefined) {
// Preserve old file format
fileFlat = oldFile.isFlat;
}
this.union(old, true);
}
log(`Writing ${filename}`);
let [contents] = this.buildContents(this.index[key], 1, fileFlat);
await fs.outputFile(filename, contents);
}
}
module.exports = async (name, plugins = []) => {
const exampleDir = resolve(__dirname, name);
const inputPath = resolve(exampleDir, 'input.css');
const outputDir = resolve(exampleDir, 'output');
const inputContent = await readFile(inputPath);
const result = await postcss(Array.isArray(plugins) ? plugins : [plugins])
.process(inputContent, { from: inputPath });
const sprite = result.messages.find(m => m.kind === 'sprite');
const readme = generateReadme(name, inputContent, result.css, sprite.content);
await outputFile(resolve(outputDir, 'output.css'), result.css);
await outputFile(resolve(outputDir, sprite.filename), sprite.content);
await outputFile(resolve(exampleDir, 'README.md'), readme);
};
async function buildFile(filename, destination, babelOptions = {}) {
if (!path.extname(filename) === '.js') return;
const content = await fse.readFile(filename, { encoding: 'utf8' });
const result = transform(content, { ...babelOptions, filename });
const output = path.join(destination, path.basename(filename));
await fse.outputFile(output, result.code);
}
return new Promise((resolve, reject) => {
fse.outputFile(targetPath, content, (err, data) => {
if (err) {
logger.error(`error occured when output file`);
reject(err);
return;
}
resolve(true);
});
});
}
const trace = lang => (req, res, next) => {
const { code } = req.body;
const tempPath = path.resolve(__dirname, '..', 'public', 'codes', uuid.v4());
fs.outputFile(path.resolve(tempPath, `Main.${lang}`), code)
.then(() => {
const builder = builderMap[lang];
const containerName = uuid.v4();
let killed = false;
const timer = setTimeout(() => {
execute(`docker kill ${containerName}`).then(() => {
killed = true;
});
}, timeLimit);
return execute([
'docker run --rm',
`--name=${containerName}`,
'-w=/usr/visualization',
`-v=${tempPath}:/usr/visualization:rw`,
`-m=${memoryLimit}m`,
'-e ALGORITHM_VISUALIZER=1',