Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(`File "${changedPath}" changed...`);
// Non-absolute paths are relative to cwd
let absPath;
if (!path.isAbsolute(changedPath)) {
absPath = path.join(process.cwd(), changedPath);
} else {
absPath = changedPath;
}
const stylesDir = path.join(process.cwd(), 'styles');
if (changedPath === '_entries.yml') {
await build(['entries', 'pages']);
} else if (pathIsInside(absPath, stylesDir)) {
await build(['webpack']);
} else {
await build(['pages', 'webpack']);
}
if (queuedPath) {
rebuild();
} else {
building = false;
}
}
);
merged.transcoder.streamQualities = [...new Set(merged.transcoder.streamQualities)].sort(
(a, b) => a - b,
);
const validationResult = this.validator.validate(merged);
if (!validationResult.success) {
throw new Error(
validationResult.errorText || 'Merged configuration schema failed to validate.',
);
}
// On the first call store the layers as the write-once base layers.
if (!this.baseLayers) {
// Some additional validation.
if (PathIsInside(Path.resolve(merged.cachePath), Path.resolve(merged.libraryPath))) {
throw new Error('Cache folder cannot be inside the library');
}
this.baseLayers = layers;
}
// Otherwise don't store the layers because they're stored in the database.
this.merged = merged;
}
}
// if this dynamic import is a concatenated string, try our best to resolve. Otherwise leave it untouched and resolve it at runtime.
try {
resolvedImportFilePath = await resolveConcatenatedImport(
rootDir,
sourceFilePath,
importPath,
config,
);
} catch (error) {
return importPath;
}
} else {
resolvedImportFilePath = await nodeResolve(rootDir, sourceFilePath, importPath, config);
}
if (!pathIsInside(resolvedImportFilePath, rootDir)) {
throw new Error(
`Import "${importPath}" resolved to the file "${resolvedImportFilePath}" which is outside the web server root, and cannot be served ` +
'by es-dev-server. Install the module locally in the current project, or expand the root directory. ' +
'If this is a symlink or if you used npm link, you can run es-dev-server with the --preserve-symlinks option',
);
}
const relativeImportFilePath = path.relative(sourceFileDir, resolvedImportFilePath);
const resolvedImportPath = toBrowserPath(relativeImportFilePath);
return resolvedImportPath.startsWith('.') ? resolvedImportPath : `./${resolvedImportPath}`;
} catch (error) {
// make module not found error message shorter
if (error.code === 'MODULE_NOT_FOUND') {
const relativeImportFilePath = path.relative(rootDir, sourceFilePath);
const resolvedImportPath = toBrowserPath(relativeImportFilePath);
const realtivePathToErrorFile = resolvedImportPath.startsWith('.')
app.get('/cache/:file(*)', (req: Request, res: Response) => {
try {
const absPath = Path.resolve(Config.get().cachePath, req.params.file);
if (!PathIsInside(absPath, Path.resolve(Config.get().cachePath))) {
throw new Error('File is not inside cache directory');
}
return res.sendFile(absPath);
} catch (err) {
return res.status(400).json({ message: err.message, type: 'config' });
}
});
async function resolveFileSystemResourceLocation(directory: string, request: RegisterFileProtocolRequest): Promise {
const resource = path.join(directory, new url.URL(request.url).pathname);
if (!pathIsInside(resource, directory)) {
throw new Error(`Forbidden file system resource "${resource}"`);
}
try {
const stat = await fsAsync.stat(resource);
if (stat.isFile()) {
return resource;
}
if (stat.isDirectory()) {
return path.join(resource, "index.html");
}
} catch (error) {
if (error.code === "ENOENT") {
return path.join(directory, "index.html");
import mkdirp from "mkdirp";
import path from "path";
import pathIsInside from "path-is-inside";
import {promisify} from "util";
import {AccountType} from "src/shared/model/account";
import {CWD, LOG, LOG_LEVELS, execShell} from "scripts/lib";
import {PROVIDER_REPO} from "src/shared/constants";
const [, , baseDestDir] = process.argv;
if (!baseDestDir) {
throw new Error(`Empty base destination directory argument`);
}
if (!pathIsInside(path.resolve(CWD, baseDestDir), CWD)) {
throw new Error(`Invalid base destination directory argument value: ${LOG_LEVELS.value(baseDestDir)}`);
}
export interface FolderAsDomainEntry {
folderNameAsDomain: string;
options: T;
}
export type Flow = (
arg: {
repoDir: string;
folderAsDomainEntry: FolderAsDomainEntry;
},
) => Promise;
export async function execAccountTypeFlow["options"]>(
export function checkFsPath(entryFsDirectory: string, fsPath: string): boolean {
const rootDirectory = getRootDirectoryPath(entryFsDirectory);
if (path.sep === '\\') {
fsPath = path.normalize(fsPath);
}
if (!pathIsInside(fsPath, rootDirectory)) {
return false;
}
return true;
}
workspaceFolder => {
return pathIsInside(entryFsDirectory, workspaceFolder.uri.fsPath);
}
);