chore(build): remove console.debug from prod

remove console.debug from prod
This commit is contained in:
Dan Bucholtz
2016-09-27 15:12:59 -05:00
parent f36b6e2d56
commit f0ac42ef49
2 changed files with 34 additions and 15 deletions

View File

@ -1,6 +1,7 @@
import { spawn, exec } from 'child_process';
import { writeFileSync } from 'fs';
import { readFileSync, writeFileSync } from 'fs';
import * as glob from 'glob';
import { dest, src, task } from 'gulp';
import { rollup } from 'rollup';
import * as commonjs from 'rollup-plugin-commonjs';
@ -12,13 +13,34 @@ import { compileSass, copyFonts, createTimestamp, setSassIonicVersion, writePoly
task('nightly', (done: (err: any) => void) => {
runSequence('release.prepareReleasePackage', 'release.publishNightly', done);
runSequence('release.prepareReleasePackage', 'release.removeDebugStatements', 'release.publishNightly', done);
});
task('release', (done: (err: any) => void) => {
runSequence('release.prepareReleasePackage', 'release.copyProdVersion', done);
// don't automatically push the button, require the user to call the publish command separately for now
runSequence('release.prepareReleasePackage', 'release.copyProdVersion', 'release.removeDebugStatements', done);
});
task('release.removeDebugStatements', (done: Function) => {
glob(`${DIST_BUILD_ROOT}/**/*.js`, (err, filePaths) => {
if (err) {
done(err);
} else {
// can make async if it's slow but it's fine for now
for (let filePath of filePaths) {
const fileContent = readFileSync(filePath).toString();
const consoleFree = replaceAll(fileContent, 'console.debug', '// console.debug');
const cleanedJs = replaceAll(consoleFree, 'debugger;', '// debugger;');
writeFileSync(filePath, cleanedJs);
}
}
});
});
function replaceAll(input: string, tokenToReplace: string, replaceWith: string) {
return input.split(tokenToReplace).join(replaceWith);
}
task('release.publishRelease', (done: Function) => {
const npmCmd = spawn('npm', ['publish', DIST_BUILD_ROOT]);
npmCmd.stdout.on('data', function (data) {

View File

@ -68,17 +68,15 @@ export class MenuContentGesture extends SlideEdgeGesture {
let shouldCompleteLeft = (velocity <= 0)
&& (velocity < -0.2 || slide.delta < -z);
console.debug(
'menu gesture, onSlide', this.menu.side,
'distance', slide.distance,
'delta', slide.delta,
'velocity', velocity,
'min', slide.min,
'max', slide.max,
'shouldCompleteLeft', shouldCompleteLeft,
'shouldCompleteRight', shouldCompleteRight,
'currentStepValue', currentStepValue);
console.debug('menu gesture, onSlide', this.menu.side);
console.debug('distance', slide.distance);
console.debug('delta', slide.delta);
console.debug('velocity', velocity);
console.debug('min', slide.min);
console.debug('max', slide.max);
console.debug('shouldCompleteLeft', shouldCompleteLeft);
console.debug('shouldCompleteRight', shouldCompleteRight);
console.debug('currentStepValue', currentStepValue);
this.menu.swipeEnd(shouldCompleteLeft, shouldCompleteRight, currentStepValue);
}
@ -104,4 +102,3 @@ export class MenuContentGesture extends SlideEdgeGesture {
};
}
}