Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
resolvePathPackage (req: string) {
if (!path.isAbsolute(req)) {
req = path.resolve(this.cwd, req)
}
const normalized = fsExistsFallback([
req,
req + '.js',
path.resolve(req, 'index.js')
])
if (!normalized) {
throw new Error(`${req} Not Found.`)
}
const dirname = path.parse(normalized).name
const { shortcut, name } = this.normalizeName(dirname)
try {
const module = this.load ? require(normalized) : normalized
return new CommonModule(module, name, shortcut, false /* fromDep */)
} catch (error) {
return getNoopModule(error)
}
}
it( 'does not fail if mrgit.json is not defined ', () => {
const cwd = path.resolve( __dirname, '..', 'fixtures', 'project-with-no-mrgitjson' );
const options = getOptions( {}, cwd );
expect( options ).to.deep.equal( {
cwd,
packages: path.resolve( cwd, 'packages' ),
resolverPath: path.resolve( __dirname, '../../lib/default-resolver.js' ),
resolverUrlTemplate: 'git@github.com:${ path }.git',
resolverTargetDirectory: 'git',
resolverDefaultBranch: 'master',
scope: null,
ignore: null,
packagesPrefix: [],
overrideDirectoryNames: {},
baseBranches: []
} );
} );
it( 'priorities passed options', () => {
const cwd = path.resolve( __dirname, '..', 'fixtures', 'project-with-options-in-mrgitjson' );
const options = getOptions( {
resolverUrlTemplate: 'a/b/c',
packages: 'bar'
}, cwd );
expect( options ).to.deep.equal( {
dependencies: {
'simple-package': 'a/b'
},
cwd,
packages: path.resolve( cwd, 'bar' ),
resolverPath: path.resolve( __dirname, '../../lib/default-resolver.js' ),
resolverUrlTemplate: 'a/b/c',
resolverTargetDirectory: 'git',
resolverDefaultBranch: 'master',
scope: null,
ignore: null,
packagesPrefix: [],
overrideDirectoryNames: {},
baseBranches: []
} );
} );
webpackPath = getPath(moduleName, isLazy, bundleName);
webpackRequireString = './' + fromPath;
} else if (stats.isFile()) {
moduleName = fromPath.split(pathSep)[0];
modulePath = path.resolve(nodeModulesList[nodeModulesIndex], moduleName);
webpackPath = getPath(fullPath, isLazy, bundleName);
webpackRequireString = './' + fromPath;
}
if (!(moduleName && modulePath)) {
_context5.next = 99;
break;
}
packageJson = path.resolve(modulePath, 'package.json');
vendorPkg = void 0;
try {
vendorPkg = JSON.parse(fileSystem.readFileSync(packageJson, 'utf8'));
} catch (_) {}
if (!vendorPkg) {
_context5.next = 97;
break;
}
mainDir = vendorPkg.main ? path.resolve(modulePath, path.dirname(vendorPkg.main)) : null;
if (!rootAlias) {
if (vendorPkg.aurelia && vendorPkg.aurelia.build && vendorPkg.aurelia.build.root) {
}).map(function (dir) {
return path.resolve(moduleDir, dir);
});
return _context.abrupt('break', 39);
case 24:
_ref = _i.value;
case 25:
moduleName = _ref;
if (!(modulesProcessed.indexOf(moduleName) === -1)) {
_context.next = 37;
break;
}
modulesProcessed.push(moduleName);
vendorPath = path.resolve(options.root, 'node_modules', moduleName);
vendorPkgPath = path.resolve(vendorPath, 'package.json');
vendorPkg = JSON.parse(fileSystem.readFileSync(vendorPkgPath, 'utf8'));
if (!(vendorPkg.browser || vendorPkg.main)) {
_context.next = 37;
break;
}
_context.t2 = dependencies;
_context.next = 35;
return getDependency(moduleName, options.root, options.root, [nodeModules], null, packageJson, options.lazy, options.bundle, undefined, undefined, true);
case 35:
_context.t3 = _context.sent;
assign(_context.t2, _context.t3);
case 37:
Template: 'template',
Snippet: 'snippet',
};
module.exports = {
ConfigFileName: '.rammyrc.json',
ComponentNameRegex: /^([a-z0-9\-_]+\/)?[a-z0-9\-_]+$/i,
ComponentType,
RammyRegion: {
Start: '%-- Rammy start',
StartFull: '%-- Rammy start ----------------',
End: '%-- Rammy end',
EndFull: '%-- Rammy end ------------------',
},
TexIgnorePath: upath.resolve(__dirname, '../assets/TeX.gitignore'),
AuxExtensions: [
'.aux',
'.lof',
'.log',
'.lot',
'.fls',
'.out',
'.toc',
'.fmt',
'.fot',
'.cb',
'.cb2',
'.bbl',
'.bcf',
'.blg',
'-blx.aux',
private getPathRelativeToInstallPath(
normalizedInstallPath: string,
maybeRelativePath: string
) {
const normalizedRelativePath = path.normalizeSafe(maybeRelativePath);
if (path.isAbsolute(normalizedRelativePath)) {
return normalizedRelativePath;
}
return path.resolve(
path.join(normalizedInstallPath, maybeRelativePath)
);
}
try {
vendorPkg = JSON.parse(fileSystem.readFileSync(packageJson, 'utf8'));
} catch (_) {}
if (!vendorPkg) {
_context5.next = 97;
break;
}
mainDir = vendorPkg.main ? path.resolve(modulePath, path.dirname(vendorPkg.main)) : null;
if (!rootAlias) {
if (vendorPkg.aurelia && vendorPkg.aurelia.build && vendorPkg.aurelia.build.root) {
rootAlias = path.resolve(modulePath, vendorPkg.aurelia.build.root);
} else if (baseVendorPkg && baseVendorPkg.aurelia && baseVendorPkg.aurelia.build && baseVendorPkg.aurelia.build.moduleRootOverride && baseVendorPkg.aurelia.build.moduleRootOverride[moduleName]) {
rootAlias = path.resolve(srcPath, baseVendorPkg.aurelia.build.moduleRootOverride[moduleName]);
} else {
rootAlias = mainDir;
}
if (rootAlias === modulePath) rootAlias = null;
}
if (doNotAdd) {
_context5.next = 60;
break;
}
_context5.next = 60;
return addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias, moduleName, modulePath);