本文整理匯總了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'));
});