本文整理汇总了TypeScript中@angular-devkit/core.getSystemPath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getSystemPath函数的具体用法?TypeScript getSystemPath怎么用?TypeScript getSystemPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getSystemPath函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switchMap
switchMap(([[browserIndexOutputPath, indexContent], serverBundlePath]) => {
const root = this.context.workspace.root;
requireProjectModule(getSystemPath(root), 'zone.js/dist/zone-node');
const renderModuleFactory = requireProjectModule(
getSystemPath(root),
'@angular/platform-server',
).renderModuleFactory;
const AppServerModuleNgFactory = require(
getSystemPath(serverBundlePath),
).AppServerModuleNgFactory;
const indexHtml = virtualFs.fileBufferToString(indexContent);
const outputPath = join(root, options.outputIndexPath || browserIndexOutputPath);
// Render to HTML and overwrite the client index file.
return from(
renderModuleFactory(AppServerModuleNgFactory, {
document: indexHtml,
url: options.route,
})
.then((html: string) => {
return this.context.host
.write(outputPath, virtualFs.stringToFileBuffer(html))
.toPromise();
})
.then(() => ({ success: true })),
);
}),
示例2: _updateWebdriver
private _updateWebdriver(projectRoot: Path) {
// The webdriver-manager update command can only be accessed via a deep import.
const webdriverDeepImport = 'webdriver-manager/built/lib/cmds/update';
let webdriverUpdate: any; // tslint:disable-line:no-any
try {
// When using npm, webdriver is within protractor/node_modules.
webdriverUpdate = requireProjectModule(getSystemPath(projectRoot),
`protractor/node_modules/${webdriverDeepImport}`);
} catch {
try {
// When using yarn, webdriver is found as a root module.
webdriverUpdate = requireProjectModule(getSystemPath(projectRoot), webdriverDeepImport);
} catch {
throw new Error(tags.stripIndents`
Cannot automatically find webdriver-manager to update.
Update webdriver-manager manually and run 'ng e2e --no-webdriver-update' instead.
`);
}
}
// run `webdriver-manager update --standalone false --gecko false --quiet`
// if you change this, update the command comment in prev line, and in `eject` task
return from(webdriverUpdate.program.run({
standalone: false,
gecko: false,
quiet: true,
}));
}
示例3: generateBrowserWebpackConfigFromWorkspace
export async function generateBrowserWebpackConfigFromWorkspace(
options: BrowserBuilderSchema,
context: BuilderContext,
projectName: string,
workspace: experimental.workspace.Workspace,
host: virtualFs.Host<fs.Stats>,
webpackPartialGenerator: (wco: BrowserWebpackConfigOptions) => webpack.Configuration[],
logger: logging.LoggerApi,
): Promise<webpack.Configuration[]> {
// TODO: Use a better interface for workspace access.
const projectRoot = resolve(workspace.root, normalize(workspace.getProject(projectName).root));
const projectSourceRoot = workspace.getProject(projectName).sourceRoot;
const sourceRoot = projectSourceRoot
? resolve(workspace.root, normalize(projectSourceRoot))
: undefined;
const normalizedOptions = normalizeBrowserSchema(
host,
workspace.root,
projectRoot,
sourceRoot,
options,
);
return generateWebpackConfig(
context,
getSystemPath(workspace.root),
getSystemPath(projectRoot),
sourceRoot && getSystemPath(sourceRoot),
normalizedOptions,
webpackPartialGenerator,
logger,
);
}
示例4: prepareBrowserConfig
// Mutates browserOptions
prepareBrowserConfig(options: CordovaBuildBuilderSchema, browserOptions: BrowserBuilderSchema) {
const cordovaBasePath = normalize(options.cordovaBasePath ? options.cordovaBasePath : '.');
// We always need to output the build to `www` because it is a hard
// requirement of Cordova.
browserOptions.outputPath = join(cordovaBasePath, normalize('www'));
if (options.cordovaAssets) {
const platformWWWPath = join(cordovaBasePath, normalize(`platforms/${options.platform}/platform_www`));
// Add Cordova www assets that were generated whenever platform(s) and
// plugin(s) are added. This includes `cordova.js`,
// `cordova_plugins.js`, and all plugin JS.
browserOptions.assets.push({
glob: '**/*',
input: getSystemPath(platformWWWPath),
output: './',
});
// Register `cordova.js` as a global script so it is included in
// `index.html`.
browserOptions.scripts.push({
input: getSystemPath(join(platformWWWPath, normalize('cordova.js'))),
bundleName: 'cordova',
lazy: false,
});
}
}
示例5: buildWebpackConfig
buildWebpackConfig(
root: Path,
projectRoot: Path,
host: virtualFs.Host<fs.Stats>,
options: NormalizedBrowserBuilderSchema,
) {
// Ensure Build Optimizer is only used with AOT.
if (options.buildOptimizer && !options.aot) {
throw new Error('The `--build-optimizer` option cannot be used without `--aot`.');
}
let wco: WebpackConfigOptions<NormalizedBrowserBuilderSchema>;
const tsConfigPath = getSystemPath(normalize(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;
wco = {
root: getSystemPath(root),
logger: this.context.logger,
projectRoot: getSystemPath(projectRoot),
buildOptions: options,
tsConfig,
tsConfigPath,
supportES2015,
};
wco.buildOptions.progress = defaultProgress(wco.buildOptions.progress);
const webpackConfigs: {}[] = [
getCommonConfig(wco),
getBrowserConfig(wco),
getStylesConfig(wco),
getStatsConfig(wco),
];
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
const typescriptConfigPartial = wco.buildOptions.aot
? getAotConfig(wco, host)
: getNonAotConfig(wco, host);
webpackConfigs.push(typescriptConfigPartial);
}
const webpackConfig = webpackMerge(webpackConfigs);
if (options.profile) {
const smp = new SpeedMeasurePlugin({
outputFormat: 'json',
outputTarget: getSystemPath(join(root, 'speed-measure-plugin.json')),
});
return smp.wrap(webpackConfig);
}
return webpackConfig;
}
示例6: buildWebpackConfig
buildWebpackConfig(
root: Path,
projectRoot: Path,
options: NormalizedBrowserBuilderSchema,
) {
let wco: WebpackConfigOptions;
const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<fs.Stats>);
const tsConfigPath = getSystemPath(normalize(resolve(root, normalize(options.tsConfig))));
const tsConfig = readTsconfig(tsConfigPath);
wco = {
root: getSystemPath(root),
logger: this.context.logger,
projectRoot: getSystemPath(projectRoot),
// TODO: use only this.options, it contains all flags and configs items already.
buildOptions: options,
tsConfig,
tsConfigPath,
supportES2015: false,
};
const webpackConfigs: {}[] = [
// We don't need to write to disk.
{ plugins: [new InMemoryOutputPlugin()] },
getCommonConfig(wco),
getAotConfig(wco, host, true),
getStylesConfig(wco),
getStatsConfig(wco),
];
return webpackMerge(webpackConfigs);
}
示例7: 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(',');
}
if (options.reporters) {
// Split along commas to make it more natural, and remove empty strings.
karmaOptions.reporters = options.reporters
.reduce<string[]>((acc, curr) => acc.concat(curr.split(/,/)), [])
.filter(x => !!x);
}
const sourceRoot = builderConfig.sourceRoot && resolve(root, builderConfig.sourceRoot);
karmaOptions.buildWebpack = {
root: getSystemPath(root),
projectRoot: getSystemPath(projectRoot),
options: options as NormalizedKarmaBuilderSchema,
webpackConfig: this._buildWebpackConfig(root, projectRoot, sourceRoot, 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();
};
})),
示例8: resolve
>((options, context) => {
const configPath = resolve(normalize(context.workspaceRoot), normalize(options.webpackConfig));
return from(import(getSystemPath(configPath))).pipe(
switchMap((config: webpack.Configuration) => runWebpackDevServer(config, context)),
);
});
示例9: beforeEach
beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../migrations.json'));
host = new TempScopedNodeJsSyncHost();
tree = new UnitTestTree(new HostTree(host));
writeFile('/tsconfig.json', JSON.stringify({
compilerOptions: {
lib: ['es2015'],
}
}));
warnOutput = [];
runner.logger.subscribe(logEntry => {
if (logEntry.level === 'warn') {
warnOutput.push(logEntry.message);
}
});
previousWorkingDir = shx.pwd();
tmpDirPath = getSystemPath(host.root);
// Switch into the temporary directory path. This allows us to run
// the schematic against our custom unit test tree.
shx.cd(tmpDirPath);
});