diff --git a/gulpfile.js b/gulpfile.js index 93971be38..a12d6aa7d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -59,6 +59,7 @@ var COMMON_WEB_FILES = [ 'web/images/*.{png,svg,gif,cur}', 'web/debugger.js' ]; +var MOZCENTRAL_DIFF_FILE = 'mozcentral.diff'; var REPO = 'git@github.com:mozilla/pdf.js.git'; var DIST_REPO_URL = 'https://github.com/mozilla/pdfjs-dist'; @@ -1372,6 +1373,36 @@ gulp.task('mozcentralbaseline', ['baseline'], function (done) { }); }); +gulp.task('mozcentraldiff', ['mozcentral', 'mozcentralbaseline'], + function (done) { + console.log(); + console.log('### Creating mozcentral diff'); + + // Create the diff between the current mozcentral build and the + // baseline mozcentral build, which both exist at this point. + // The mozcentral baseline directory is a Git repository, so we + // remove all files and copy the current mozcentral build files + // into it to create the diff. + rimraf.sync(MOZCENTRAL_BASELINE_DIR + '*'); + + gulp.src([BUILD_DIR + 'mozcentral/**/*']) + .pipe(gulp.dest(MOZCENTRAL_BASELINE_DIR)) + .on('end', function () { + spawnSync('git', ['add', '-A'], {cwd: MOZCENTRAL_BASELINE_DIR}); + var diff = spawnSync('git', + ['diff', '--binary', '--cached', '--unified=8'], + {cwd: MOZCENTRAL_BASELINE_DIR}).stdout; + + createStringSource(MOZCENTRAL_DIFF_FILE, diff) + .pipe(gulp.dest(BUILD_DIR)) + .on('end', function () { + console.log('Result diff can be found at ' + BUILD_DIR + + MOZCENTRAL_DIFF_FILE); + done(); + }); + }); +}); + // Getting all shelljs registered tasks and register them with gulp require('./make.js'); diff --git a/make.js b/make.js index 7030aa8fc..1263476d2 100644 --- a/make.js +++ b/make.js @@ -227,34 +227,7 @@ target.mozcentralbaseline = function() { }; target.mozcentraldiff = function() { - target.mozcentral(); - - cd(ROOT_DIR); - - echo(); - echo('### Creating mozcentral diff'); - - var MOZCENTRAL_DIFF = BUILD_DIR + 'mozcentral.diff'; - if (test('-f', MOZCENTRAL_DIFF)) { - rm(MOZCENTRAL_DIFF); - } - - var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline'; - if (!test('-d', MOZCENTRAL_BASELINE_DIR)) { - echo('mozcentral baseline was not found'); - echo('Please build one using "gulp mozcentralbaseline"'); - exit(1); - } - cd(MOZCENTRAL_BASELINE_DIR); - exec('git reset --hard'); - cd(ROOT_DIR); rm('-rf', MOZCENTRAL_BASELINE_DIR + '/*'); // trying to be safe - cd(MOZCENTRAL_BASELINE_DIR); - cp('-Rf', '../mozcentral/*', '.'); - exec('git add -A'); - exec('git diff --binary --cached --unified=8', {silent: true}).output. - to('../mozcentral.diff'); - - echo('Result diff can be found at ' + MOZCENTRAL_DIFF); + execGulp('mozcentraldiff'); }; ////////////////////////////////////////////////////////////////////////////////