本文整理匯總了TypeScript中@angular-devkit/core.resolve函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript resolve函數的具體用法?TypeScript resolve怎麽用?TypeScript resolve使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了resolve函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: _deleteOutputDir
private _deleteOutputDir(root: Path, outputPath: Path, host: virtualFs.Host) {
const resolvedOutputPath = resolve(root, outputPath);
if (resolvedOutputPath === root) {
throw new Error('Output path MUST not be project root directory!');
}
return host.exists(resolvedOutputPath).pipe(
concatMap(exists => exists
// TODO: remove this concat once host ops emit an event.
? concat(host.delete(resolvedOutputPath), of(null)).pipe(last())
// ? of(null)
: of(null)),
);
}
示例2: concatMap
concatMap(buildEvent => {
if (buildEvent.success && !options.watch && options.serviceWorker) {
return from(augmentAppWithServiceWorker(
host,
root,
projectRoot,
resolve(root, normalize(options.outputPath)),
options.baseHref || '/',
options.ngswConfigPath,
).then(() => ({ success: true }), () => ({ success: false })));
} else {
return of(buildEvent);
}
}),
示例3: constructor
constructor(
private _compilerOptions: CompilerOptions,
_basePath: string,
private _JitMode: boolean,
private _rootNames: string[],
hostReplacementPaths: { [path: string]: string },
) {
time('TypeChecker.constructor');
const host = new virtualFs.AliasHost(new NodeJsSyncHost());
// Add file replacements.
for (const from in hostReplacementPaths) {
const normalizedFrom = resolve(normalize(_basePath), normalize(from));
const normalizedWith = resolve(
normalize(_basePath),
normalize(hostReplacementPaths[from]),
);
host.aliases.set(normalizedFrom, normalizedWith);
}
const compilerHost = new WebpackCompilerHost(
_compilerOptions,
_basePath,
host,
true,
);
// We don't set a async resource loader on the compiler host because we only support
// html templates, which are the only ones that can throw errors, and those can be loaded
// synchronously.
// If we need to also report errors on styles then we'll need to ask the main thread
// for these resources.
this._compilerHost = createCompilerHost({
options: this._compilerOptions,
tsHost: compilerHost,
}) as CompilerHost & WebpackCompilerHost;
timeEnd('TypeChecker.constructor');
}
示例4: concatMap
concatMap(() => new Observable(obs => {
const karma = requireProjectModule(getSystemPath(projectRoot), 'karma');
const karmaConfig = getSystemPath(resolve(root, normalize(options.karmaConfig)));
// TODO: adjust options to account for not passing them blindly to karma.
// const karmaOptions: any = Object.assign({}, options);
// tslint:disable-next-line:no-any
const karmaOptions: any = {};
if (options.watch !== undefined) {
karmaOptions.singleRun = !options.watch;
}
// Convert browsers from a string to an array
if (options.browsers) {
karmaOptions.browsers = options.browsers.split(',');
}
karmaOptions.buildWebpack = {
root: getSystemPath(root),
projectRoot: getSystemPath(projectRoot),
options: options as NormalizedKarmaBuilderSchema,
webpackConfig: this._buildWebpackConfig(root, projectRoot, host,
options as NormalizedKarmaBuilderSchema),
// Pass onto Karma to emit BuildEvents.
successCb: () => obs.next({ success: true }),
failureCb: () => obs.next({ success: false }),
};
// TODO: inside the configs, always use the project root and not the workspace root.
// Until then we pretend the app root is relative (``) but the same as `projectRoot`.
karmaOptions.buildWebpack.options.root = '';
// Assign additional karmaConfig options to the local ngapp config
karmaOptions.configFile = karmaConfig;
// Complete the observable once the Karma server returns.
const karmaServer = new karma.Server(karmaOptions, () => obs.complete());
karmaServer.start();
// Cleanup, signal Karma to exit.
return () => {
// Karma does not seem to have a way to exit the server gracefully.
// See https://github.com/karma-runner/karma/issues/2867#issuecomment-369912167
// TODO: make a PR for karma to add `karmaServer.close(code)`, that
// calls `disconnectBrowsers(code);`
// karmaServer.close();
};
})),
示例5: augmentAppWithServiceWorker
const callback: webpack.compiler.CompilerCallback = (err, stats) => {
if (err) {
return obs.error(err);
}
const json = stats.toJson(statsConfig);
if (options.verbose) {
this.context.logger.info(stats.toString(statsConfig));
} else {
this.context.logger.info(statsToString(json, statsConfig));
}
if (stats.hasWarnings()) {
this.context.logger.warn(statsWarningsToString(json, statsConfig));
}
if (stats.hasErrors()) {
this.context.logger.error(statsErrorsToString(json, statsConfig));
}
if (options.watch) {
obs.next({ success: !stats.hasErrors() });
// Never complete on watch mode.
return;
} else {
if (builderConfig.options.serviceWorker) {
augmentAppWithServiceWorker(
this.context.host,
root,
projectRoot,
resolve(root, normalize(options.outputPath)),
options.baseHref || '/',
options.ngswConfigPath,
).then(
() => {
obs.next({ success: !stats.hasErrors() });
obs.complete();
},
(err: Error) => {
// We error out here because we're not in watch mode anyway (see above).
obs.error(err);
},
);
} else {
obs.next({ success: !stats.hasErrors() });
obs.complete();
}
}
};
示例6: run
run(builderConfig: BuilderConfiguration<ProtractorBuilderOptions>): Observable<BuildEvent> {
const options = builderConfig.options;
const root = this.context.workspace.root;
const projectRoot = resolve(root, builderConfig.root);
// const projectSystemRoot = getSystemPath(projectRoot);
// TODO: verify using of(null) to kickstart things is a pattern.
return of(null).pipe(
concatMap(() => options.devServerTarget ? this._startDevServer(options) : of(null)),
concatMap(() => options.webdriverUpdate ? this._updateWebdriver(projectRoot) : of(null)),
concatMap(() => this._runProtractor(root, options)),
take(1),
);
}
示例7: buildWebpackConfig
buildWebpackConfig(
root: Path,
projectRoot: Path,
sourceRoot: Path | undefined,
host: virtualFs.Host<fs.Stats>,
options: NormalizedKarmaBuilderSchema,
) {
let wco: WebpackConfigOptions;
const tsConfigPath = getSystemPath(resolve(root, normalize(options.tsConfig)));
const tsConfig = readTsconfig(tsConfigPath);
const projectTs = requireProjectModule(getSystemPath(projectRoot), 'typescript') as typeof ts;
const supportES2015 = tsConfig.options.target !== projectTs.ScriptTarget.ES3
&& tsConfig.options.target !== projectTs.ScriptTarget.ES5;
const compatOptions: typeof wco['buildOptions'] = {
...options as {} as typeof wco['buildOptions'],
// Some asset logic inside getCommonConfig needs outputPath to be set.
outputPath: '',
};
wco = {
root: getSystemPath(root),
logger: this.context.logger,
projectRoot: getSystemPath(projectRoot),
sourceRoot: sourceRoot && getSystemPath(sourceRoot),
// TODO: use only this.options, it contains all flags and configs items already.
buildOptions: compatOptions,
tsConfig,
tsConfigPath,
supportES2015,
};
wco.buildOptions.progress = defaultProgress(wco.buildOptions.progress);
const webpackConfigs: {}[] = [
getCommonConfig(wco),
getStylesConfig(wco),
getNonAotTestConfig(wco, host),
getTestConfig(wco),
];
return webpackMerge(webpackConfigs);
}
示例8: run
run(builderConfig: BuilderConfiguration<Partial<Schema>>): Observable<BuildEvent> {
const projectRoot = getSystemPath(resolve(this.context.workspace.root, builderConfig.root));
const targetLabel = builderConfig.options.targetLabel;
const executable = builderConfig.options.watch ? 'ibazel' : 'bazel';
if (!checkInstallation(executable, projectRoot)) {
throw new Error(
`Could not run ${executable}. Please make sure that the ` +
`"${executable}" command is available in the $PATH.`);
}
// TODO: Support passing flags.
return runBazel(
projectRoot, executable, builderConfig.options.bazelCommand !, targetLabel !,
[] /* flags */)
.pipe(map(() => ({success: true})), catchError(() => of ({success: false})), );
}
示例9: Observable
return new Observable(obs => {
augmentAppWithServiceWorker(
this.context.host,
root,
projectRoot,
resolve(root, normalize(options.outputPath)),
options.baseHref || '/',
options.ngswConfigPath,
).then(
() => {
obs.next({ success: true });
obs.complete();
},
(err: Error) => {
obs.error(err);
},
);
});
示例10: run
run(builderConfig: BuilderConfiguration<BuildWebpackServerSchema>): Observable<BuildEvent> {
const options = builderConfig.options;
const root = this.context.workspace.root;
const projectRoot = resolve(root, builderConfig.root);
const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<Stats>);
const webpackBuilder = new WebpackBuilder({ ...this.context, host });
// TODO: verify using of(null) to kickstart things is a pattern.
return of(null).pipe(
concatMap(() => options.deleteOutputPath
? this._deleteOutputDir(root, normalize(options.outputPath), this.context.host)
: of(null)),
concatMap(() => addFileReplacements(root, host, options.fileReplacements)),
concatMap(() => {
const webpackConfig = this.buildWebpackConfig(root, projectRoot, host, options);
return webpackBuilder.runWebpack(webpackConfig, getBrowserLoggingCb(options.verbose));
}),
);
}