本文整理汇总了TypeScript中gulp-string-replace类的典型用法代码示例。如果您正苦于以下问题:TypeScript gulp-string-replace类的具体用法?TypeScript gulp-string-replace怎么用?TypeScript gulp-string-replace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了gulp-string-replace类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: RegExp
gulp.task('remove:mock', () => {
console.log('Removing mock import');
return gulp.src(['./src/app/app.module.ts', './src/app/app.component.ts']) // Any file globs are supported
.pipe(replace(new RegExp(`// import './shared/mock';`, 'g'), `import './shared/mock';`, { logs: { enabled: false } })) // Prevent adding new comment markers
.pipe(replace(new RegExp(`import './shared/mock';`, 'g'), `// import './shared/mock';`, { logs: { enabled: false } })) // Comment out import line
.pipe(gulp.dest('./src/app'));
});
示例2: moment
gulp.task('clean:version-lib', (next) => {
const v = npmconfig.version;
const b = moment().seconds(0).milliseconds(0).valueOf();
return gulp.src(['./lib/src/widgets.module.ts']) // Any file globs are supported
.pipe(replace(/public static version = '[0-9a-zA-Z.-]*'/g, `public static version = 'local-dev'`, { logs: { enabled: true } }))
.pipe(replace(/private build = moment\([0-9]*\);/g, `private build = moment();`, { logs: { enabled: true } }))
.pipe(gulp.dest('./lib/src'));
});
示例3: dayjs
gulp.task('clean:version-lib', (next) => {
const v = npmconfig.version;
const b = dayjs().startOf('m').valueOf();
return gulp.src(['./lib/src/composer.module.ts']) // Any file globs are supported
.pipe(replace(/public static version = '[0-9a-zA-Z.-]*'/g, `public static version = 'local-dev'`, { logs: { enabled: true } }))
.pipe(replace(/private build = dayjs\([0-9]*\);/g, `private build = dayjs();`, { logs: { enabled: true } }))
.pipe(gulp.dest('./lib/src'));
});