Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test.each(testCases)("programmatic: %j", async testCase => {
await bestzip(
Object.assign(
{ destination, cwd: path.join(__dirname, "../", testCase.cwd) },
testCase
)
);
await unzip(destination, tmpdir);
const structure = getStructure(tmpdir);
expect(structure).toMatchSnapshot();
if (testCase.structure) {
expect(structure).toEqual(testCase.structure);
} else {
// the structure is defined in the first test run, so it may not be defined when running subsets of tests
console.log("skipping structure match");
}
});
assert.strictEqual(path.toNamespacedPath(file),
`\\\\?\\${resolvedFile}`);
assert.strictEqual(path.toNamespacedPath(`\\\\?\\${file}`),
`\\\\?\\${resolvedFile}`);
assert.strictEqual(path.toNamespacedPath(
'\\\\someserver\\someshare\\somefile'),
'\\\\?\\UNC\\someserver\\someshare\\somefile');
assert.strictEqual(path.toNamespacedPath(
'\\\\?\\UNC\\someserver\\someshare\\somefile'),
'\\\\?\\UNC\\someserver\\someshare\\somefile');
assert.strictEqual(path.toNamespacedPath('\\\\.\\pipe\\somepipe'),
'\\\\.\\pipe\\somepipe');
}
assert.strictEqual(path.toNamespacedPath(''), '');
assert.strictEqual(path.toNamespacedPath(null), null);
assert.strictEqual(path.toNamespacedPath(100), 100);
assert.strictEqual(path.toNamespacedPath(path), path);
assert.strictEqual(path.toNamespacedPath(false), false);
assert.strictEqual(path.toNamespacedPath(true), true);
const emptyObj = {};
assert.strictEqual(path.posix.toNamespacedPath('/foo/bar'), '/foo/bar');
assert.strictEqual(path.posix.toNamespacedPath('foo/bar'), 'foo/bar');
assert.strictEqual(path.posix.toNamespacedPath(null), null);
assert.strictEqual(path.posix.toNamespacedPath(true), true);
assert.strictEqual(path.posix.toNamespacedPath(1), 1);
assert.strictEqual(path.posix.toNamespacedPath(), undefined);
assert.strictEqual(path.posix.toNamespacedPath(emptyObj), emptyObj);
if (common.isWindows) {
// These tests cause resolve() to insert the cwd, so we cannot test them from
// non-Windows platforms (easily)
if (-1 != ignore.indexOf(dirEntry))
continue;
var linkName = dirEntry;
var realBaseName = dirEntry;
var realLoc = scanPath + path.sep + dirEntry;
var entryStat = fs.lstatSync(realLoc);
if (entryStat.isSymbolicLink()) {
realLoc = fs.realpathSync(realLoc);
entryStat = fs.statSync(realLoc);
realBaseName = realLoc.split(/[\\/]/).pop();
}
if (entryStat.isDirectory()) {
var modEntry = fromJS([]).asMutable();
var isMod = false;
// check if it's a mod
var modName = this.parseFileForName(realLoc + path.sep + "mod.cpp");
var metaName = this.parseFileForName(realLoc + path.sep + "meta.cpp");
if (!modName && !metaName) {
// last try: check for addons directory
if (this.checkDirAccessible(realLoc + path.sep + "addons") || this.checkDirAccessible(realLoc + path.sep + "Addons")) {
isMod = true;
modName = metaName = ""; //dirEntry;
if (this.isAllNumbers(dirEntry) && !this.isAllNumbers(realBaseName)) {
linkName = realBaseName;
}
} else {
console.log("Failed entry: " + dirEntry + ": no .cpp files, no addons directory");
}
} else {
isMod = true;
if (!!modName && !!metaName) {
if (modName.length < metaName.length) {
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) { }
}
});
}
const getFileInfo = (file) => {
const existingFrontMatter = file.frontMatter;
let relativePath = path.relative(constants.dirs.CONTENT, file.dest);
let root = '';
let baseName;
if (relativePath.startsWith('docs')) {
relativePath = path.relative('docs', relativePath);
root = 'docs';
}
baseName = path.basename(relativePath, '.md');
baseName = baseName !== 'index' ? baseName : '';
const splittedPath = path.dirname(relativePath).split(path.sep);
const section = splittedPath[0];
const tocTitle = splittedPath[1];
const originalFile = normalize(path.join(root, relativePath)).toLowerCase();
const newFrontMatter = {
contentType: getContentType(originalFile),
description: getPredefinedDescription(file.dest) || getDescription(file.content),
isMultiHints: file.isMulti,
// Define witch ejs layout is going to be used for Hexo.
layout: getLayout(file.dest),
originalFile,
permalink: normalize(path.join(root, path.dirname(relativePath), baseName, 'index.html')).toLowerCase(),
/**
function forcelink(src, dest, options, callback) {
if (!options || !options.cache) throw new Error('options.cache not defined!');
if (!callback) throw new Error('callback not defined!');
// uses relative path if linking to cache dir
if (path.relative) {
src = path.relative(options.cache, dest).slice(0, 2) !== '..' ? path.relative(path.dirname(dest), src) : src;
}
fs.lstat(dest, function(err, stat) {
// Error.
if (err && err.code !== 'ENOENT') {
return callback(err);
}
// Path does not exist. Symlink.
if (err && err.code === 'ENOENT') {
if (env == 'development') console.error("[millstone] linking '" + dest + "' -> '" + src + "'");
return fs.symlink(src, dest, callback);
}
// Path exists and is not a symlink. Do nothing.
if (!stat.isSymbolicLink()) {
if (env == 'development') console.error("[millstone] skipping re-linking '" + src + "' because '" + dest + " is already an existing file");
private static _normalizeDeepestParentFolderPath(folderPath: string): string | undefined {
folderPath = path.normalize(folderPath);
const endsWithSlash: boolean = folderPath.charAt(folderPath.length - 1) === path.sep;
const parsedPath: path.ParsedPath = path.parse(folderPath);
const pathRoot: string = parsedPath.root;
const pathWithoutRoot: string = parsedPath.dir.substr(pathRoot.length);
const pathParts: string[] = [...pathWithoutRoot.split(path.sep), parsedPath.name].filter((part) => !!part);
// Starting with all path sections, and eliminating one from the end during each loop iteration,
// run trueCasePathSync. If trueCasePathSync returns without exception, we've found a subset
// of the path that exists and we've now gotten the correct casing.
//
// Once we've found a parent folder that exists, append the path sections that didn't exist.
for (let i: number = pathParts.length; i >= 0; i--) {
const constructedPath: string = path.join(pathRoot, ...pathParts.slice(0, i));
try {
const normalizedConstructedPath: string = trueCasePathSync(constructedPath);
const result: string = path.join(normalizedConstructedPath, ...pathParts.slice(i));
exports.findExecutable = (command, cwd, options) => {
// If we have an absolute path then we take it.
if (path.isAbsolute(command)) {
return command
}
let dir = path.dirname(command)
if (dir !== '.') {
// We have a directory and the directory is relative (see above). Make the path absolute
// to the current working directory.
return path.join(cwd, command)
}
let paths
// The options can override the PATH. So consider that PATH if present.
if (options && options.env) {
// Path can be named in many different ways and for the execution it doesn't matter
for (let key of Object.keys(options.env)) {
if (key.toLowerCase() === 'path') {
if (typeof options.env[key] === 'string') {
paths = options.env[key].split(path.delimiter)
linkClicked(text: string, dir: string) {
const { file, line = 1, column = 0 } = parseGoPosition(text)
let filepath
if (path.isAbsolute(file)) {
filepath = file
} else {
const base = dir || projectPath()
if (!base) {
return
}
filepath = path.join(base, file)
}
const col = column && column > 0 ? column - 1 : 0
openFile(filepath, { row: line - 1, column: col }).catch(err => {
console.log('could not access ' + file, err) // eslint-disable-line no-console
})
}