mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
chore(build): remove console.debug from prod
remove console.debug from prod
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { spawn, exec } from 'child_process';
|
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 { dest, src, task } from 'gulp';
|
||||||
import { rollup } from 'rollup';
|
import { rollup } from 'rollup';
|
||||||
import * as commonjs from 'rollup-plugin-commonjs';
|
import * as commonjs from 'rollup-plugin-commonjs';
|
||||||
@ -12,13 +13,34 @@ import { compileSass, copyFonts, createTimestamp, setSassIonicVersion, writePoly
|
|||||||
|
|
||||||
|
|
||||||
task('nightly', (done: (err: any) => void) => {
|
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) => {
|
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) => {
|
task('release.publishRelease', (done: Function) => {
|
||||||
const npmCmd = spawn('npm', ['publish', DIST_BUILD_ROOT]);
|
const npmCmd = spawn('npm', ['publish', DIST_BUILD_ROOT]);
|
||||||
npmCmd.stdout.on('data', function (data) {
|
npmCmd.stdout.on('data', function (data) {
|
||||||
|
@ -68,17 +68,15 @@ export class MenuContentGesture extends SlideEdgeGesture {
|
|||||||
let shouldCompleteLeft = (velocity <= 0)
|
let shouldCompleteLeft = (velocity <= 0)
|
||||||
&& (velocity < -0.2 || slide.delta < -z);
|
&& (velocity < -0.2 || slide.delta < -z);
|
||||||
|
|
||||||
console.debug(
|
console.debug('menu gesture, onSlide', this.menu.side);
|
||||||
'menu gesture, onSlide', this.menu.side,
|
console.debug('distance', slide.distance);
|
||||||
'distance', slide.distance,
|
console.debug('delta', slide.delta);
|
||||||
'delta', slide.delta,
|
console.debug('velocity', velocity);
|
||||||
'velocity', velocity,
|
console.debug('min', slide.min);
|
||||||
'min', slide.min,
|
console.debug('max', slide.max);
|
||||||
'max', slide.max,
|
console.debug('shouldCompleteLeft', shouldCompleteLeft);
|
||||||
'shouldCompleteLeft', shouldCompleteLeft,
|
console.debug('shouldCompleteRight', shouldCompleteRight);
|
||||||
'shouldCompleteRight', shouldCompleteRight,
|
console.debug('currentStepValue', currentStepValue);
|
||||||
'currentStepValue', currentStepValue);
|
|
||||||
|
|
||||||
this.menu.swipeEnd(shouldCompleteLeft, shouldCompleteRight, currentStepValue);
|
this.menu.swipeEnd(shouldCompleteLeft, shouldCompleteRight, currentStepValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,4 +102,3 @@ export class MenuContentGesture extends SlideEdgeGesture {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user