Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _pathModuleFor(uri: NuclideUri): typeof pathModule {
invariant(
!_endsWithArchiveSeparator(uri),
`Path cannot end with archive separator. Failed to determine path module for ${uri}`,
);
if (uri.startsWith(pathModule.posix.sep)) {
return pathModule.posix;
}
if (uri.indexOf('://') > -1) {
return pathModule.posix;
}
if (uri[1] === ':' && uri[2] === pathModule.win32.sep) {
return pathModule.win32;
}
// This little russian roulette here is blocking T29990593. I didn't
// clean it because we might see posix paths on windows and vice versa.
if (
uri.split(pathModule.win32.sep).length >
uri.split(pathModule.posix.sep).length
) {
return pathModule.win32;
} else {
async function fingerprintRemainingAssets (ctx: PluginContext, bundle: OutputBundle, manifest: AssetsManifest) {
const remainingAssets = resolveEntrypointAssets(config.root)
for (const [filename, absoluteFilename] of remainingAssets) {
const content = await fsp.readFile(absoluteFilename)
const hash = getAssetHash(content)
const ext = path.extname(filename)
const filenameWithoutExt = filename.slice(0, -ext.length)
const hashedFilename = path.posix.join(config.build.assetsDir, `${path.basename(filenameWithoutExt)}.${hash}${ext}`)
manifest.set(filename, { file: hashedFilename, src: filename })
// Avoid duplicates if the file was referenced in a different entrypoint.
if (!bundle[hashedFilename])
ctx.emitFile({ name: filename, fileName: hashedFilename, type: 'asset', source: content })
}
}
apkUtilsMethods.cacheApk = async function cacheApk (apkPath, options = {}) {
const appHash = await fs.hash(apkPath);
const remotePath = path.posix.join(REMOTE_CACHE_ROOT, `${appHash}.apk`);
const remoteCachedFiles = [];
// Get current contents of the remote cache or create it for the first time
try {
const errorMarker = '_ERROR_';
let lsOutput = null;
if (this._areExtendedLsOptionsSupported === true || !_.isBoolean(this._areExtendedLsOptionsSupported)) {
lsOutput = await this.shell([`ls -t -1 ${REMOTE_CACHE_ROOT} 2>&1 || echo ${errorMarker}`]);
}
if (!_.isString(lsOutput) || (lsOutput.includes(errorMarker) && !lsOutput.includes(REMOTE_CACHE_ROOT))) {
if (!_.isBoolean(this._areExtendedLsOptionsSupported)) {
log.debug('The current Android API does not support extended ls options. ' +
'Defaulting to no-options call');
}
lsOutput = await this.shell([`ls ${REMOTE_CACHE_ROOT} 2>&1 || echo ${errorMarker}`]);
this._areExtendedLsOptionsSupported = false;
} else {
}
for(let i = 0; i < candidateFromPaths.length; i++) {
let candidatePath;
let candidateFromPath = normalizePath(makeAbsolute(candidateFromPaths[i]));
if (path.isAbsolute(url)) {
candidatePath = normalizePath(url);
} else {
// Get normalize absolute candidate from path
candidatePath = path.posix.join(candidateFromPath, url);
}
if(includedFilesMap[candidatePath]) {
return candidatePath;
} else {
let urlBasename = path.posix.basename(url);
let indexOfBasename = url.lastIndexOf(urlBasename);
let partialUrl = `${url.substring(0, indexOfBasename)}_${urlBasename}`;
if (path.isAbsolute(partialUrl)) {
candidatePath = normalizePath(partialUrl);
} else {
candidatePath = path.posix.join(candidateFromPath, partialUrl);
}
if(includedFilesMap[candidatePath]) {
return candidatePath;
}
}
}
return null;
const router = express.Router();
router.use(auth.webUIJWTmiddleware());
router.use(setSecurityWebHeaders);
const themePath = loadTheme(config) || require('@verdaccio/ui-theme')();
const indexTemplate = path.join(themePath, 'index.html');
const template = fs.readFileSync(indexTemplate).toString();
// Logo
let logoURI = _.get(config, 'web.logo') ? config.web.logo : '';
if (logoURI && !isHTTPProtocol(logoURI)) {
// URI related to a local file
// Note: `path.join` will break on Windows, because it transforms `/` to `\`
// Use POSIX version `path.posix.join` instead.
logoURI = path.posix.join('/-/static/', path.basename(logoURI));
router.get(logoURI, function(req, res, next) {
res.sendFile(path.resolve(config.web.logo), sendFileCallback(next));
});
}
// Static
router.get('/-/static/*', function(req, res, next) {
const filename = req.params[0];
const file = `${themePath}/${filename}`;
res.sendFile(file, sendFileCallback(next));
});
function renderHTML(req, res) {
const protocol = getWebProtocol(req.get(HEADERS.FORWARDED_PROTO), req.protocol);
const host = req.get('host');
const { url_prefix } = config;
silent (dir, ref) {
if (ref.startsWith('./')) return path.posix.join('~', ref + '.js')
if (ref.startsWith('/')) return ref + '.js'
return path.posix.join('~', ref, 'index.js')
}
}
function assetsPath (_path) {
return path.posix.join('./', _path)
}
function getNormalizedInstruction() {
const files = project.build.copyFiles2;
let normalizedInstruction = {};
for (let key in files) {
normalizedInstruction[path.posix.normalize(key)] = files[key];
}
return normalizedInstruction;
}
function assetsPath (_path) {
return path.posix.join('assets/', _path)
}
const genTsLintConfig: Generator = (appPath, ownPath, ownPkg) => {
const tsLintConfigPath = path.join(appPath, 'tslint.json')
const builinTsLintConfigPath = path.posix.join(ownPkg.name, 'lib/tslint.json')
if (fs.existsSync(tsLintConfigPath)) {
const config = json5.parse(fs.readFileSync(tsLintConfigPath).toString()) as {
extends?: string | string[]
defaultSeverity?: string
}
let dirty: boolean = false
if (config.extends) {
if (typeof config.extends === 'string' && config.extends !== builinTsLintConfigPath) {
config.extends = [builinTsLintConfigPath, config.extends]
dirty = true
} else if (config.extends.indexOf(builinTsLintConfigPath) === -1) {
;(config.extends as string[]).unshift(builinTsLintConfigPath)
dirty = true
}
}