Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function main() {
// Rename all bazel files found by prefixing them with `_`
const cwd = process.cwd();
const rootNodeModules =
/\/node_modules\/@bazel\/hide-bazel-files$/.test(cwd.replace(/\\/g, '/')) ?
path.dirname(path.dirname(cwd)) :
path.posix.join(cwd, 'node_modules');
for (f of findBazelFiles(rootNodeModules)) {
const d = path.posix.join(path.dirname(f), `_${path.basename(f)}`);
fs.renameSync(f, d);
}
return 0;
}
parser.hooks.program.tap("Aurelia:ConventionDependencies", () => {
const { resource: file, rawRequest } = parser.state.current;
if (!file)
return;
// We don't want to bring in dependencies of the async! loader
if (/^async[!?]/.test(rawRequest))
return;
if (!minimatch(path.relative(root, file), this.glob))
return;
for (let c of this.conventions) {
try {
const probe = c(file);
compilation.inputFileSystem.statSync(probe); // Check if file exists
let relative = path.relative(path.dirname(file), probe);
if (!relative.startsWith("."))
relative = "./" + relative;
addDependency(relative);
// If the module has a conventional dependency, make sure we preserve its name as well.
// This solves the pattern where a VM is statically loaded, e.g. `import { ViewModel } from "x"`
// and then passed to Aurelia, e.g. with `aurelia-dialog`.
// At this point Aurelia must determine the origin of the module to be able to look for
// a conventional view, and so the module name must be preserved although it's never loaded
// by `aurelia-loader`. See also aurelia/metadata#51.
parser.state.current[PreserveModuleNamePlugin_1.preserveModuleName] = true;
}
catch (ex) { }
}
});
}
resolve: function(id, parentOpts, cb) {
// set the basedir properly so we don't try to resolve requires in the Closure
// Compiler processed `node_modules` folder.
parentOpts.basedir =
parentOpts.filename === filename
? path.resolve(__dirname)
: path.dirname(parentOpts.filename);
resolver(parentOpts.basedir, id, cb);
},
filter: function(id) {
xfs.mkdir(p, mode, function (er) {
if (!er) {
made = made || p;
return cb(null, made);
}
switch (er.code) {
case 'ENOENT':
if (path.dirname(p) === p) return cb(er);
mkdirP(path.dirname(p), opts, function (er, made) {
if (er) cb(er, made);
else mkdirP(p, opts, cb, made);
});
break;
// In the case of any other error, just see if there's a dir
// there already. If so, then hooray! If not, then something
// is borked.
default:
xfs.stat(p, function (er2, stat) {
// if the stat fails, then that's super weird.
// let the original error be the failure reason.
if (er2 || !stat.isDirectory()) cb(er, made)
else cb(null, made);
});
}, function (cb) {
var ext = '.stdout';
var output = clc.green('Passed all ' + totalTests + ' tests!');
if (failingTests.length > 0) {
ext = '.stderr';
output = clc.red(
'Failed ' + failingTests.length +
' out of ' + totalTests + ' tests.');
var failedOutput = '';
for (let failingTest of failingTests) {
failedOutput += clc.red(path.dirname(failingTest.path) +
': ' + path.basename(failingTest.path, ext)) + '\n ';
}
this.push(new File({
path: path.join('Failing Tests', 'summary' + ext),
contents: new Buffer(failedOutput)
}));
}
this.push(new File({
path: path.join('Summary', 'summary' + ext),
contents: new Buffer(output)
}));
cb();
});
function doWrite(destRelativePath, html) {
let destPath = path.resolve(config.releaseDestDir, destRelativePath);
fse.ensureDirSync(path.dirname(destPath));
fs.writeFileSync(destPath, html, 'utf8');
console.log(chalk.green(`generated: ${destPath}`));
}
}
this.capi.TABLE_URL = tableurl;
if(!IS_NODE) {
this.capi.FS.lookup = bindDynLoader(this);
} else {
this.disableOnDemandTableLoading();
this.capi.FS.mkdir('/tables');
var tablefolder = tableurl;
if(!tablefolder) {
var path = require('path');
var buildpath = require.resolve('liblouis-build');
tablefolder = path.resolve(path.dirname(buildpath), "tables/");
}
try {
this.capi.FS.mount(this.capi.FS.filesystems.NODEFS, { root: tablefolder }, '/tables');
} catch(e) {
console.error(e);
throw new Error("mounting of table folder failed");
}
}
},
throw new Error('Please, specify question title');
}
const questionName = agrs[0];
const srcDir = `${path.dirname(require.main.filename)}/../../content/questions`;
const existingQuestions = getDirectories(srcDir);
if (existingQuestions.indexOf(questionName) > -1) {
throw new Error(`Question ${questionName} already exists. Please, specify another name`);
}
mkdirSync(`${srcDir}/${questionName}`, (err) => {
if (err) throw err;
});
const fileTemplate = readFileSync(`${path.dirname(require.main.filename)}/index.md`, 'utf8');
const blankQuestionTmpl = template(fileTemplate);
writeFileSync(`${srcDir}/${questionName}/index.md`, blankQuestionTmpl({
order: existingQuestions.length,
date: new Date(),
}));
console.info('All done!');
}
var editor = window.activeTextEditor;
if(!checkFileSelected()) {
return false;
}
if (!editor || !editor.document) {
return false;
}
var fileUri = editor.document.uri;
//If folder not opened, run p4 in files folder.
if(checkFolderOpened()) {
edit(fileUri);
} else {
edit(fileUri, Path.dirname(fileUri.fsPath));
}
}
constructor(params) {
if (!params) {
throw new Error('Template initialization failed!');
}
const dirname = path.dirname(params.path);
const pkgPath = path.join(dirname, 'package.json');
const pkg = utils.safeRequire(pkgPath);
if (!pkg) {
throw new Error(`Template package.json is not found at ${pkgPath}`);
}
pkg.docmaTemplate = pkg.docmaTemplate || {};
/** @private */
this._ = _.extend({}, params, {
dirname,
pkg,
templateDir: path.join(dirname, 'template'),
initialOptions: (params.buildConfig.template || {}).options || {},
defaultOptions: null,
mainHTML: '',
compile: null,