本文整理汇总了TypeScript中gulp.task函数的典型用法代码示例。如果您正苦于以下问题:TypeScript task函数的具体用法?TypeScript task怎么用?TypeScript task使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了task函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: join
// Paths to the different tsconfig files of the Universal app.
// Building the sources in the output directory is part of the workaround for
// https://github.com/angular/angular/issues/12249
const tsconfigAppPath = join(outDir, 'tsconfig-build.json');
const tsconfigPrerenderPath = join(outDir, 'tsconfig-prerender.json');
/** Path to the compiled prerender file. Running this file just dumps the HTML output for now. */
const prerenderOutFile = join(outDir, 'prerender.js');
/** Task that builds the universal-app and runs the prerender script. */
task('prerender', ['universal:build'], execTask(
// Runs node with the tsconfig-paths module to alias the @angular/material dependency.
'node', ['-r', 'tsconfig-paths/register', prerenderOutFile], {
env: {TS_NODE_PROJECT: tsconfigPrerenderPath},
// Errors in lifecycle hooks will write to STDERR, but won't exit the process with an
// error code, however we still want to catch those cases in the CI.
failOnStderr: true
}
));
task(
'universal:build',
sequenceTask(
'clean',
[
'cdk:build-release',
'material:build-release',
'cdk-experimental:build-release',
'material-experimental:build-release',
],
示例2: task
import {task} from 'gulp';
import {serverTask} from '../task_helpers';
task('serve', serverTask());
示例3: task
import { spawn } from 'child_process';
import { createServer } from 'http';
import { join, resolve } from 'path';
import * as connect from 'connect';
import { task } from 'gulp';
import * as serveStatic from 'serve-static';
import { argv } from 'yargs';
import { DIST_E2E_COMPONENTS_ROOT, PROJECT_ROOT, SCRIPTS_ROOT } from '../constants';
import { mergeObjects } from '../util';
task('snapshot', ['e2e.prod'], (done: Function) => {
snapshot(false, done);
});
task('snapshot.skipBuild', (done: Function) => {
snapshot(false, done);
});
function snapshot(quickMode: boolean, callback: Function) {
const snapshotConfig = require('../../snapshot/snapshot.config').config;
const protractorConfigFile = resolve(SCRIPTS_ROOT, 'snapshot/protractor.config.js');
const snapshotDefaults = snapshotConfig.platformDefaults || {};
const snapshotValues: any = mergeObjects(snapshotDefaults, argv || {});
if (!snapshotConfig.accessKey || !snapshotConfig.accessKey.length) {
console.error('Missing IONIC_SNAPSHOT_KEY environment variable');
return callback(new Error('Missing IONIC_SNAPSHOT_KEY environment variable'));
示例4: task
import {task} from 'gulp';
import {join} from 'path';
import {DIST_ROOT} from '../constants';
import {execNodeTask, sequenceTask} from '../util/task_helpers';
/**
* Prepares the AOT compilation by copying the demo-app and building the components with their
* associated metadata files from the Angular compiler.
*/
task('aot:deps', sequenceTask(
'build:devapp',
':build:components:release')
);
/** Build the demo-app and a release to confirm that the library is AOT-compatible. */
task('aot:build', sequenceTask('aot:deps', 'aot:compiler-cli'));
/** Build the demo-app and a release to confirm that the library is AOT-compatible. */
task('aot:compiler-cli', execNodeTask(
'@angular/compiler-cli', 'ngc', ['-p', join(DIST_ROOT, 'tsconfig-aot.json')]
));
示例5: require
const install = require("gulp-install");
const vfs = require('vinyl-fs');
const symlink = require('gulp-sym');
const bump = require('gulp-bump');
const indexDirectory = require('../builder/index-directory');
const beautify = require('gulp-beautify');
const path = require('path');
require('babel-register');
require('app-module-path').addPath(`../npm-link`);
const dirName = path.basename(process.cwd());
gulp.task('default', [
'transpile',
'copy-assets',
// 'link-shattered-lib', 'link-rot-js', 'link-jcson',
// 'install-node-modules'
]);
gulp.task('transpile',
[
'watch-transpile',
'copy-assets',
'index-components',
'index-entity-templates',
'index-level-generators'
], () =>
gulp.src(['**/*.js', "!gulpfile.js", '!{node_modules,node_modules/**}'])
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(beautify({ indentSize: 2 }))
示例6: if
if (b.hasOwnProperty(f)) {
if (!a[f]) {
a[f] = b[f];
} else if (typeof b[f] === 'object' && typeof a[f] === 'object') {
mergeJSON(a[f], b[f]);
} else {
a[f] = b[f];
}
}
}
};
/**
* Nuke old build assetts.
*/
gulp.task('clean', () => ((...globs: string[]) => del(globs))('dist/', 'compiled/', '_package'));
gulp.task('default', ['build']);
gulp.task('package:lib', () => packagr());
gulp.task('pre-build:lib', (next) => runSequence('update:version-lib', next));
gulp.task('pre-build', (next) => {
const sequence = ['check:route', 'sw:base', 'update:version', 'settings:update', next];
if (!argv.mock && argv.demo !== true) { sequence.splice(2, 0, ['remove:mock']); }
runSequence(...sequence);
});
gulp.task('pre-serve', (next) => runSequence(
'check:flags',
示例7: join
/** Path to the directory where all releases are living. */
const releasesDir = join(outputDir, 'releases');
/** Path to the demo-app source directory. */
const demoAppSource = join(packagesDir, 'demo-app');
/** Path to the demo-app output directory. */
const demoAppOut = join(outputDir, 'packages', 'demo-app');
/** Path to the tsconfig file that builds the AOT files. */
const tsconfigFile = join(demoAppOut, 'tsconfig-aot.json');
/** Builds the demo-app and material. To be able to run NGC, apply the metadata workaround. */
task('aot:deps', sequenceTask(
['material:build-release', 'cdk:build-release', 'material-moment-adapter:build-release'],
[':build:devapp:assets', ':build:devapp:scss', 'aot:copy-devapp', 'aot:copy-release'],
));
// As a workaround for https://github.com/angular/angular/issues/12249, we need to
// copy the Material and CDK ESM output inside of the demo-app output.
task('aot:copy-release', () => {
copySync(join(releasesDir, 'material'), join(demoAppOut, 'material'));
copySync(join(releasesDir, 'cdk'), join(demoAppOut, 'cdk'));
copySync(
join(releasesDir, 'material-moment-adapter'), join(demoAppOut, 'material-moment-adapter'));
});
// // As a workaround for https://github.com/angular/angular/issues/12249, we need to
// copy the demo-app sources to distribution and run the NGC inside of the dist folder.
task('aot:copy-devapp', () => copySync(demoAppSource, demoAppOut));
示例8:
///<reference path="gulp-insert.d.ts" />
///<reference path="../gulp/gulp.d.ts" />
import * as gulp from 'gulp';
import * as insert from 'gulp-insert';
gulp.task('gulp-insert-tests', () => {
return gulp.src('*.js')
.pipe(insert.prepend('/* Inserted using gulp-insert prepend method */\n'))
.pipe(insert.prepend('\n/* Inserted using gulp-insert append method */'))
.pipe(insert.wrap(
'/* Inserted using gulp-insert wrap method */\n',
'\n/* Inserted using gulp-insert wrap method */'
))
.pipe(insert.transform((contents, file) => {
var comment = '/* Local file: ' + file.path + ' */\n';
return comment + contents;
}))
.pipe(gulp.dest('gulp-insert'));
});
示例9: task
// NOTE: there are two build "modes" in this file, based on which tsconfig is used.
// When `tsconfig.json` is used, we are outputting ES6 modules and a UMD bundle. This is used
// for serving and for release.
//
// When `tsconfig-spec.json` is used, we are outputting CommonJS modules. This is used
// for unit tests (karma).
/** Path to the tsconfig used for ESM output. */
const tsconfigPath = path.relative(PROJECT_ROOT, path.join(COMPONENTS_DIR, 'tsconfig.json'));
/** [Watch task] Rebuilds (ESM output) whenever ts, scss, or html sources change. */
task(':watch:components', () => {
watch(path.join(COMPONENTS_DIR, '**/*.ts'), ['build:components', triggerLivereload]);
watch(path.join(COMPONENTS_DIR, '**/*.scss'), ['build:components', triggerLivereload]);
watch(path.join(COMPONENTS_DIR, '**/*.html'), ['build:components', triggerLivereload]);
});
/** Builds component typescript only (ESM output). */
task(':build:components:ts', tsBuildTask(COMPONENTS_DIR, 'tsconfig-srcs.json'));
/** Builds components typescript for tests (CJS output). */
task(':build:components:spec', tsBuildTask(COMPONENTS_DIR));
/** Copies assets (html, markdown) to build output. */
task(':build:components:assets', copyTask([
path.join(COMPONENTS_DIR, '**/*.!(ts|spec.ts)'),
path.join(PROJECT_ROOT, 'README.md'),
path.join(PROJECT_ROOT, 'LICENSE'),
示例10: minimist
import {buildConfig} from '../packaging/build-config';
import {yellow, green, red, grey} from 'chalk';
import * as minimist from 'minimist';
/** Packages that will be published to NPM by the release task. */
export const releasePackages = [
'cdk',
'material',
];
/** Parse command-line arguments for release task. */
const argv = minimist(process.argv.slice(3));
/** Task that builds all releases that will be published. */
task(':publish:build-releases', sequenceTask(
'clean',
releasePackages.map(packageName => `${packageName}:build-release`)
));
/** Make sure we're logged in. */
task(':publish:whoami', execTask('npm', ['whoami'], {
silent: true,
errMessage: 'You must be logged in to publish.'
}));
task(':publish:logout', execTask('npm', ['logout']));
function _execNpmPublish(label: string, packageName: string): Promise<{}> {
const packageDir = join(buildConfig.outputDir, 'releases', packageName);
if (!statSync(packageDir).isDirectory()) {