path#isAbsolute TypeScript Examples
The following examples show how to use
path#isAbsolute.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From karma-test-explorer with MIT License | 7 votes |
isChildPath = (parentPath: string, childPath: string): boolean => {
const childFromParentRelativePath = relative(parentPath, childPath);
return (
childPath !== parentPath &&
!isAbsolute(childFromParentRelativePath) &&
!childFromParentRelativePath.startsWith('..')
);
}
Example #2
Source File: index.ts From web with MIT License | 6 votes |
function getMatcher(patterns?: string[]) {
if (!patterns || patterns.length === 0) {
return () => true;
}
const key = patterns.join('');
let matcher = cachedMatchers.get(key);
if (!matcher) {
const resolvedPatterns = patterns.map(pattern =>
!isAbsolute(pattern) && !pattern.startsWith('*')
? posix.join(coverageBaseDir, pattern)
: pattern,
);
matcher = picoMatch(resolvedPatterns);
cachedMatchers.set(key, matcher);
}
return matcher;
}
Example #3
Source File: utils.ts From cli with MIT License | 6 votes |
transformToRelative = (baseDir: string, targetDir: string) => {
if (targetDir) {
if (isAbsolute(targetDir)) {
return relative(baseDir, targetDir);
}
return targetDir;
}
}
Example #4
Source File: migrate.ts From vscode-rss with MIT License | 6 votes |
export async function checkStoragePath(context: vscode.ExtensionContext): Promise<string> {
const old = context.globalState.get<string>('root', context.globalStoragePath);
const cfg = vscode.workspace.getConfiguration('rss');
const root = cfg.get<string>('storage-path') || context.globalStoragePath;
if (old !== root) {
if (!isAbsolute(root)) {
throw Error(`"${root}" is not an absolute path`);
}
if (!await fileExists(root) || await isDirEmpty(root)) {
await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: 'Moving data...',
cancellable: false
}, async () => {
await checkDir(old);
try {
await moveFile(old, root);
} catch (e: any) {
throw Error(`Move data failed: ${e.toString()}`);
}
});
} else {
const s = await vscode.window.showInformationMessage(
`Target directory "${root}" is not empty, use this directory?`,
'Yes', "Cancel"
);
if (s !== 'Yes') {
// revert the configuration
await cfg.update('storage-path', old, true);
await checkDir(old);
return old;
}
}
await context.globalState.update('root', root);
}
await checkDir(root);
return root;
}
Example #5
Source File: index.ts From cli with MIT License | 6 votes |
generate = (
sourceFilePathOrJson: any,
targetFilePath: string,
builderCls?
) => {
let baseDir = process.cwd();
let transformResultJSON = {};
if (typeof sourceFilePathOrJson === 'string') {
if (!isAbsolute(sourceFilePathOrJson)) {
sourceFilePathOrJson = join(baseDir, sourceFilePathOrJson);
} else {
baseDir = dirname(sourceFilePathOrJson);
}
}
transformResultJSON = transform(sourceFilePathOrJson, builderCls);
if (!isAbsolute(targetFilePath)) {
targetFilePath = join(baseDir, targetFilePath);
}
return saveYaml(targetFilePath, transformResultJSON);
}
Example #6
Source File: typeorm-uml.class.ts From typeorm-uml with MIT License | 6 votes |
/**
* Get path for file.
*
* @private
* @param {string} filename The output filename.
* @returns {string} The resolved full path of file.
*/
private getPath( filename: string ): string {
return !isAbsolute( filename ) ? resolve( process.cwd(), filename ) : filename;
}
Example #7
Source File: typeorm-uml.class.ts From typeorm-uml with MIT License | 6 votes |
/**
* Creates and returns Typeorm connection based on selected configuration file.
*
* @async
* @private
* @param {string} configPath A path to Typeorm config file.
* @param {Flags} flags An object with command flags.
* @returns {Connection} A connection instance.
*/
private async getConnection( configPath: string, flags: Flags ): Promise<Connection> {
let root = process.cwd();
let configName = configPath;
if ( isAbsolute( configName ) ) {
root = dirname( configName );
configName = basename( configName );
}
const cwd = dirname( resolve( root, configName ) );
process.chdir( cwd );
const connectionOptionsReader = new ConnectionOptionsReader( { root, configName } );
const connectionOptions = await connectionOptionsReader.get( flags.connection || 'default' );
return getConnectionManager().create( connectionOptions );
}
Example #8
Source File: moduleExists.ts From vite-plugin-ssr with MIT License | 6 votes |
function moduleExists(modulePath: string, dirPath?: string): boolean {
if (!isAbsolute(modulePath)) {
assert(dirPath)
assert(isAbsolute(dirPath))
modulePath = resolve(dirPath, modulePath)
}
assert(isAbsolute(modulePath))
// `req` instead of `require` in order to skip Webpack's dependency analysis
const req = require
try {
req.resolve(modulePath)
return true
} catch (err) {
return false
}
}
Example #9
Source File: prerender.ts From vite-plugin-ssr with MIT License | 6 votes |
function assertArguments({
partial,
noExtraDir,
base,
root,
outDir,
parallel,
}: {
partial: unknown
noExtraDir: unknown
base: unknown
root: unknown
outDir: unknown
parallel: number
}) {
assertUsage(partial === true || partial === false, '[prerender()] Option `partial` should be a boolean.')
assertUsage(noExtraDir === true || noExtraDir === false, '[prerender()] Option `noExtraDir` should be a boolean.')
assertWarning(base === undefined, '[prerender()] Option `base` is deprecated and has no-effect.')
assertUsage(typeof root === 'string', '[prerender()] Option `root` should be a string.')
assertUsage(isAbsolute(root), '[prerender()] The path `root` is not absolute. Make sure to provide an absolute path.')
assertUsage(typeof outDir === 'string', '[prerender()] Option `outDir` should be a string.')
assertUsage(parallel, `[prerender()] Option \`parallel\` should be a number \`>=1\` but we got \`${parallel}\`.`)
}
Example #10
Source File: isChildPath.ts From backstage with Apache License 2.0 | 6 votes |
/**
* Checks if path is the same as or a child path of base.
*
* @public
*/
export function isChildPath(base: string, path: string): boolean {
const relativePath = relative(base, path);
if (relativePath === '') {
// The same directory
return true;
}
const outsideBase = relativePath.startsWith('..'); // not outside base
const differentDrive = isAbsolute(relativePath); // on Windows, this means dir is on a different drive from base.
return !outsideBase && !differentDrive;
}
Example #11
Source File: svelte-check.ts From language-tools with MIT License | 6 votes |
private async initialize(workspacePath: string, options: SvelteCheckOptions) {
if (options.tsconfig && !isAbsolute(options.tsconfig)) {
throw new Error('tsconfigPath needs to be absolute, got ' + options.tsconfig);
}
this.configManager.update({
svelte: {
compilerWarnings: options.compilerWarnings,
useNewTransformation: options.useNewTransformation ?? false
}
});
// No HTMLPlugin, it does not provide diagnostics
if (shouldRegister('svelte')) {
this.pluginHost.register(new SveltePlugin(this.configManager));
}
if (shouldRegister('css')) {
this.pluginHost.register(new CSSPlugin(this.docManager, this.configManager));
}
if (shouldRegister('js') || options.tsconfig) {
this.lsAndTSDocResolver = new LSAndTSDocResolver(
this.docManager,
[pathToUrl(workspacePath)],
this.configManager,
undefined,
true,
options.tsconfig
);
this.pluginHost.register(
new TypeScriptPlugin(this.configManager, this.lsAndTSDocResolver)
);
}
function shouldRegister(source: SvelteCheckDiagnosticSource) {
return !options.diagnosticSources || options.diagnosticSources.includes(source);
}
}
Example #12
Source File: paths.ts From Cromwell with MIT License | 6 votes |
getModulePackage = async (moduleName?: string): Promise<TPackageJson | undefined> => {
const logger = getLogger();
let pPath: string | undefined = moduleName ?? process.cwd();
if (!isAbsolute(pPath)) {
try {
pPath = resolvePackageJsonPath(pPath);
} catch (error) { }
}
if (moduleName && (!pPath || !isAbsolute(pPath))) {
try {
// if module is a root package
const rootPackage = await getModulePackage();
if (rootPackage?.name === moduleName) return rootPackage;
} catch (e) { }
}
if (pPath && !pPath.endsWith('package.json')) pPath = pPath + '/package.json';
if (pPath) pPath = normalizePath(pPath);
try {
if (pPath) return await readPackage(pPath);
} catch (e) { logger.error('Failed to read package.json at: ' + pPath) }
}
Example #13
Source File: template.ts From fantasticon with MIT License | 6 votes |
renderTemplate = async (
templatePath: string,
context: object,
options: CompileOptions = {}
) => {
const absoluteTemplatePath = isAbsolute(templatePath)
? templatePath
: resolve(process.cwd(), templatePath);
const template = await readFile(absoluteTemplatePath, 'utf8');
return Handlebars.compile(template)(context, {
...options,
helpers: { ...TEMPLATE_HELPERS, ...(options.helpers || {}) }
});
}
Example #14
Source File: paths.ts From Cromwell with MIT License | 6 votes |
getCmsModuleConfig = async (moduleName?: string): Promise<TModuleConfig | undefined> => {
const path = moduleName ? isAbsolute(moduleName) ? moduleName :
await getNodeModuleDir(moduleName) : process.cwd();
if (path) {
const configPath = resolve(path, configFileName);
try {
return require(configPath);
} catch (e) { }
}
}
Example #15
Source File: moduleExists.ts From telefunc with MIT License | 6 votes |
function moduleExists(modulePath: string, dir?: string): boolean {
if (!isAbsolute(modulePath)) {
assert(dir)
modulePath = resolve(dir, modulePath)
}
assert(isAbsolute(modulePath))
try {
nodeRequire.resolve(modulePath)
return true
} catch (err) {
return false
}
}
Example #16
Source File: index.ts From nestjs-proto-gen-ts with MIT License | 6 votes |
private generate(path: string, pkg: string): void {
let hbTemplate = resolve(__dirname, '../..', this.options.template);
//If absolute path we will know have custom template option
if (isAbsolute(path)) {
hbTemplate = path;
}
if (!existsSync(hbTemplate)) {
throw new Error(`Template ${hbTemplate} is not found`);
}
const tmpl = readFileSync(hbTemplate, 'utf8');
if (this.options.verbose) {
console.log(chalk.blueBright(`-- found: `) + chalk.gray(path));
}
this.output(path, pkg, tmpl);
}
Example #17
Source File: workspace.ts From nx-dotnet with MIT License | 5 votes |
export function getDependantProjectsForNxProject(
targetProject: string,
workspaceConfiguration: WorkspaceJsonConfiguration,
forEachCallback?: (
project: ProjectConfiguration & { projectFile: string },
projectName: string,
implicit: boolean,
) => void,
): {
[projectName: string]: ProjectConfiguration;
} {
const projectRoots: { [key: string]: string } = {};
const dependantProjects: { [key: string]: ProjectConfiguration } = {};
Object.entries(workspaceConfiguration.projects).forEach(([name, project]) => {
projectRoots[name] = normalizePath(resolve(project.root));
});
const absoluteNetProjectFilePath = resolve(
workspaceRoot,
getProjectFileForNxProjectSync(
workspaceConfiguration.projects[targetProject],
),
);
const netProjectFilePath = relative(
workspaceRoot,
absoluteNetProjectFilePath,
);
const hostProjectDirectory = normalizePath(dirname(netProjectFilePath));
const xml: XmlDocument = new XmlDocument(
readFileSync(absoluteNetProjectFilePath).toString(),
);
xml.childrenNamed('ItemGroup').forEach((itemGroup) =>
itemGroup.childrenNamed('ProjectReference').forEach((x: XmlElement) => {
const includeFilePath = normalizePath(x.attr['Include']);
const implicit = x.attr['ReferenceOutputAssembly'] === 'false';
const workspaceFilePath = normalizePath(
isAbsolute(includeFilePath)
? includeFilePath
: resolve(hostProjectDirectory, includeFilePath),
);
Object.entries(projectRoots).forEach(([dependency, path]) => {
if (workspaceFilePath.startsWith(`${path}/`)) {
if (forEachCallback) {
forEachCallback(
{
...workspaceConfiguration.projects[dependency],
projectFile: workspaceFilePath,
},
dependency,
implicit,
);
}
dependantProjects[dependency] =
workspaceConfiguration.projects[dependency];
}
});
}),
);
return dependantProjects;
}
Example #18
Source File: executor.spec.ts From nx-dotnet with MIT License | 5 votes |
describe('Publish Executor', () => {
let context: ExecutorContext;
let dotnetClient: jest.Mocked<DotNetClient>;
beforeEach(() => {
context = {
root: root,
cwd: root,
projectName: 'my-app',
targetName: 'publish',
workspace: {
version: 2,
projects: {
'my-app': {
root: `${root}/apps/my-app`,
sourceRoot: `${root}/apps/my-app`,
targets: {
publish: {
executor: '@nx-dotnet/core:publish',
},
},
},
},
npmScope: 'unit-tests',
},
isVerbose: false,
};
dotnetClient = new DotNetClient(
mockDotnetFactory(),
) as jest.Mocked<DotNetClient>;
});
it('calls publish when 1 project file is found', async () => {
const res = await executor(options, context, dotnetClient);
expect(dotnetClient.publish).toHaveBeenCalled();
expect(res.success).toBeTruthy();
});
it('should pass path relative to project root, not workspace root', async () => {
const directoryPath = joinPathFragments(root, './apps/my-app');
const res = await executor(options, context, dotnetClient);
expect(dotnetClient.publish).toHaveBeenCalled();
expect(normalizePath(dotnetClient.cwd || '')).toEqual(directoryPath);
expect(res.success).toBeTruthy();
});
it('passes an absolute output path', async () => {
const spy = jest.spyOn(dotnetClient, 'publish');
const res = await executor(options, context, dotnetClient);
expect(spy).toHaveBeenCalled();
const outputFlag = spy.mock.calls[0][1]?.output;
expect(outputFlag).toBeTruthy();
expect(outputFlag && isAbsolute(outputFlag as string)).toBeTruthy();
expect(res.success).toBeTruthy();
});
});
Example #19
Source File: cms-modules.ts From Cromwell with MIT License | 5 votes |
readCmsModules = async (dir?: string) => {
const themes: string[] = [];
const plugins: string[] = [];
const processed: string[] = [];
const readPackageCmsModules = async (packageName: string, root?: boolean) => {
if (processed.includes(packageName)) return;
processed.push(packageName);
let packagePath;
try {
packagePath = isAbsolute(packageName) ? packageName : resolvePackageJsonPath(packageName);
} catch (error) { }
if (packagePath) {
let pckg: TPackageJson | undefined;
try {
pckg = await readPackage(packagePath);
} catch (error) { }
if (!pckg) return;
if (!pckg.cromwell && !root) return;
const packageThemes = pckg?.cromwell?.themes ?? [];
const packagePlugins = pckg?.cromwell?.plugins ?? [];
if (pckg.name && pckg.cromwell?.type === 'theme') packageThemes.push(pckg.name);
if (pckg.name && pckg.cromwell?.type === 'plugin') packagePlugins.push(pckg.name);
for (const themeName of packageThemes) {
if (!themes.includes(themeName)) {
themes.push(themeName);
}
}
for (const pluginName of packagePlugins) {
if (!plugins.includes(pluginName)) {
plugins.push(pluginName);
}
}
const childPackages = [
...Object.keys(pckg.dependencies ?? {}),
...Object.keys(pckg.peerDependencies ?? {}),
...Object.keys(pckg.devDependencies ?? {}),
...packagePlugins,
...packageThemes,
];
const childPromises: Promise<any>[] = [];
childPackages.forEach(moduleName => {
childPromises.push(readPackageCmsModules(moduleName));
});
await Promise.all(childPromises);
}
}
await readPackageCmsModules(cmsPackageName);
await readPackageCmsModules(resolve(dir ?? process.cwd(), 'package.json'), true);
return {
themes,
plugins
}
}
Example #20
Source File: mimeTypesPlugin.ts From web with MIT License | 5 votes |
function createMatcher(rootDir: string, pattern: string) {
const resolvedPattern =
!isAbsolute(pattern) && !pattern.startsWith('*') ? posix.join(rootDir, pattern) : pattern;
return picoMatch(resolvedPattern, { dot: true });
}
Example #21
Source File: paths.ts From coffeesense with MIT License | 5 votes |
export function normalizeAbsolutePath(fsPath: string, root: string) {
return isAbsolute(fsPath) ? normalizeFileNameToFsPath(fsPath) : normalizeFileNameResolve(root, fsPath);
}
Example #22
Source File: telefuncConfig.ts From telefunc with MIT License | 5 votes |
configSpec = {
isProduction: {
validate(val: unknown) {
assertUsage(val === true || val === false, '`telefuncConfig.isProduction` should be `true` or `false`')
},
getDefault() {
// If server environment is not a Node.js server, then we assume a (Cloudflare) worker environment
if (typeof process == 'undefined' || !hasProp(process, 'env')) return true
return process.env.NODE_ENV === 'production'
}
},
root: {
validate(val: unknown) {
assertUsage(typeof val === 'string' && isAbsolute(val), '`telefuncConfig.root` should be an absolute path')
},
getDefault() {
if (typeof process == 'undefined' || !hasProp(process, 'cwd')) return null
return process.cwd()
}
},
viteDevServer: {
validate(val: unknown) {
assertInfo(
false,
'`telefuncConfig.viteDevServer` is not needed anymore. Remove your `telefuncConfig.viteDevServer` configuration to get rid of this message. (Telefunc now automatically retrieves the Vite dev server.)'
)
assertUsage(hasProp(val, 'ssrLoadModule'), '`telefuncConfig.ssrLoadModule` should be the Vite dev server')
assertUsage(
(val as any as ViteDevServer).config.plugins.find((plugin) => plugin.name.startsWith('telefunc')),
'Telefunc Vite plugin not installed. Make sure to add Telefunc to your `vite.config.js`.'
)
assert(val === globalContext.viteDevServer, '`viteDevServer` mismatch.')
},
getDefault() {
return null
}
},
telefuncUrl: {
validate(val: unknown) {
assertUsage(
typeof val === 'string' && val.startsWith('/'),
'`telefuncConfig.telefuncUrl` should be a string that starts with `/`'
)
},
getDefault() {
return '/_telefunc'
}
},
telefuncFiles: {
validate(val: unknown) {
assertWarning(false, '`telefuncConfig.telefuncFiles` is experimental', { onlyOnce: true })
assertUsage(
Array.isArray(val) && val.every((v) => typeof v === 'string' && isAbsolute(v)),
'`telefuncConfig.telefuncFiles` should be a list of absolute paths'
)
},
getDefault() {
return null
}
},
disableEtag: {
validate(_val: unknown) {
assertWarning(false, '`telefuncConfig.disableEtag` is experimental', { onlyOnce: true })
},
getDefault() {
return false
}
},
debug: {
validate(val: unknown) {
assertUsage(typeof val === 'boolean', '`telefuncConfig.debug` should be a boolean')
},
getDefault() {
if (typeof process == 'undefined' || !hasProp(process, 'env')) return false
return !!process.env.DEBUG
}
}
}
Example #23
Source File: index.ts From cli with MIT License | 5 votes |
private transformToAbsolute(baseDir, targetDir) {
if (targetDir) {
if (!isAbsolute(targetDir)) {
return join(baseDir, targetDir);
}
return targetDir;
}
}
Example #24
Source File: index.ts From cli with MIT License | 5 votes |
private transformToRelative(baseDir, targetDir) {
if (targetDir) {
if (isAbsolute(targetDir)) {
return relative(baseDir, targetDir);
}
return targetDir;
}
}
Example #25
Source File: index.ts From cli with MIT License | 5 votes |
async package() {
this.core.cli.log('Package artifact...');
// 跳过打包
if (this.options.skipZip) {
this.core.cli.log(' - Zip artifact skip');
if (this.core.service?.experimentalFeatures?.removeUselessFiles) {
this.core.cli.log(' - Experimental Feature RemoveUselessFiles');
await removeUselessFiles(this.midwayBuildPath);
}
return;
}
// 构建打包
const packageObj: any = this.core.service.package || {};
let file = join(this.servicePath, this.zipCodeDefaultName);
if (packageObj.artifact) {
if (isAbsolute(packageObj.artifact)) {
file = packageObj.artifact;
} else {
file = join(this.servicePath, packageObj.artifact);
}
}
this.setStore('artifactFile', file, true);
this.core.cli.log(` - Artifact file ${relative(this.servicePath, file)}`);
// 保证文件存在,然后删了文件,只留目录
await ensureFile(file);
await remove(file);
await this.makeZip(this.midwayBuildPath, file);
const stat = statSync(file);
this.setStore('zipSize', stat.size, true);
this.core.cli.log(
` - Zip size ${Number(stat.size / (1024 * 1024)).toFixed(2)}MB`
);
if (this.options.package) {
const to = resolve(this.servicePath, this.options.package);
await move(file, to);
}
}
Example #26
Source File: NoteWorkspace.ts From vscode-markdown-notes with GNU General Public License v3.0 | 5 votes |
static createNewNoteFile(noteTitle: string) {
let workspacePath = '';
if (vscode.workspace.workspaceFolders) {
workspacePath = vscode.workspace.workspaceFolders[0].uri.fsPath.toString();
}
const activeFile = vscode.window.activeTextEditor?.document;
let activePath = activeFile ? dirname(activeFile.uri.fsPath) : null;
let noteDirectory = this.newNoteDirectory();
// first handle the case where we try to use same dir as active note:
if (noteDirectory == this.NEW_NOTE_SAME_AS_ACTIVE_NOTE) {
if (activePath) {
noteDirectory = activePath;
} else {
vscode.window.showWarningMessage(
`Error. newNoteDirectory was NEW_NOT_SAME_AS_ACTIVE_NOTE but no active note directory found. Using WORKSPACE_ROOT.`
);
noteDirectory = this.NEW_NOTE_WORKSPACE_ROOT;
}
}
// next, handle a case where this is set to a custom path
if (noteDirectory != this.NEW_NOTE_WORKSPACE_ROOT) {
// If the noteDirectory was set from the current activePath,
// it will already be absolute.
// Also, might as well handle case where user has
// an absolute path in their settings.
if (!isAbsolute(noteDirectory)) {
noteDirectory = join(workspacePath, noteDirectory);
}
const dirExists = existsSync(noteDirectory);
if (!dirExists) {
vscode.window.showWarningMessage(
`Error. newNoteDirectory \`${noteDirectory}\` does not exist. Using WORKSPACE_ROOT.`
);
noteDirectory = this.NEW_NOTE_WORKSPACE_ROOT;
}
}
// need to recheck this in case we handled correctly above.
// on errors, we will have set to this value:
if (noteDirectory == this.NEW_NOTE_WORKSPACE_ROOT) {
noteDirectory = workspacePath;
}
const filename = NoteWorkspace.noteFileNameFromTitle(noteTitle);
const filepath = join(noteDirectory, filename);
const fileAlreadyExists = existsSync(filepath);
if (fileAlreadyExists) {
vscode.window.showWarningMessage(
`Error creating note, file at path already exists: ${filepath}`
);
} else {
// create the file if it does not exist
const contents = NoteWorkspace.newNoteContent(noteTitle);
writeFileSync(filepath, contents);
}
return {
filepath: filepath,
fileAlreadyExists: fileAlreadyExists,
};
}
Example #27
Source File: injectAssets.ts From vite-plugin-ssr with MIT License | 5 votes |
async function getPageAssets(
pageContext: {
_allPageFiles: AllPageFiles
_baseUrl: string
_baseAssets: string | null
},
dependencies: string[],
pageClientFilePath: string,
isPreRendering: boolean,
): Promise<PageAsset[]> {
assert(dependencies.every((filePath) => isAbsolute(filePath)))
const { isProduction = false } = getSsrEnv()
let clientManifest: null | ViteManifest = null
let serverManifest: null | ViteManifest = null
if (isPreRendering || isProduction) {
const manifests = retrieveViteManifest(isPreRendering)
clientManifest = manifests.clientManifest
serverManifest = manifests.serverManifest
}
const preloadAssets: string[] = await getPreloadUrls(pageContext, dependencies, clientManifest, serverManifest)
let pageAssets: PageAsset[] = preloadAssets.map((src) => {
const { mediaType = null, preloadType = null } = inferMediaType(src) || {}
const assetType = mediaType === 'text/css' ? 'style' : 'preload'
return {
src,
assetType,
mediaType,
preloadType,
}
})
const scriptSrc = !isProduction ? pageClientFilePath : resolveScriptSrc(pageClientFilePath, clientManifest!)
pageAssets.push({
src: scriptSrc,
assetType: 'script',
mediaType: 'text/javascript',
preloadType: null,
})
pageAssets = pageAssets.map((pageAsset) => {
const baseUrlAssets = pageContext._baseAssets || pageContext._baseUrl
pageAsset.src = prependBaseUrl(normalizePath(pageAsset.src), baseUrlAssets)
return pageAsset
})
sortPageAssetsForHttpPush(pageAssets)
return pageAssets
}
Example #28
Source File: getAbsolutePath.ts From typescript-strict-plugin with MIT License | 5 votes |
export function getAbsolutePath(projectRootPath: string, filePath: string): string {
if (isAbsolute(filePath)) return filePath;
return resolve(projectRootPath, filePath);
}
Example #29
Source File: paths.ts From Cromwell with MIT License | 5 votes |
isExternalForm = id => !id.startsWith('\0') && !id.startsWith('.') && !id.startsWith('/') && !isAbsolute(id) && !id.startsWith('$$')