[Pkg-javascript-commits] [pdf.js] 265/414: Migrate `clean` and `importl10n` target to gulp

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 96cca2b37acfe43f9a12763c0329185cb1595170
Author: Tim van der Meij <timvandermeij at gmail.com>
Date:   Fri Mar 4 21:14:56 2016 +0100

    Migrate `clean` and `importl10n` target to gulp
---
 external/importL10n/locales.js | 10 +++++-----
 gulpfile.js                    | 24 ++++++++++++++++++++++++
 make.js                        | 20 ++------------------
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/external/importL10n/locales.js b/external/importL10n/locales.js
index a3c5be3..b8a590d 100644
--- a/external/importL10n/locales.js
+++ b/external/importL10n/locales.js
@@ -41,7 +41,7 @@ function normalizeText(s) {
   return s.replace(/\r\n?/g, '\n').replace(/\uFEFF/g, '');
 }
 
-function downloadLanguageFiles(langCode, callback) {
+function downloadLanguageFiles(root, langCode, callback) {
   console.log('Downloading ' + langCode + '...');
 
   // Constants for constructing the URLs. Translations are taken from the
@@ -56,12 +56,12 @@ function downloadLanguageFiles(langCode, callback) {
   var downloadsLeft = files.length;
 
   if (!fs.existsSync(langCode)) {
-    fs.mkdirSync(langCode);
+    fs.mkdirSync(path.join(root, langCode));
   }
 
   // Download the necessary files for this language.
   files.forEach(function(fileName) {
-    var outputPath = path.join(langCode, fileName);
+    var outputPath = path.join(root, langCode, fileName);
     var url = MOZCENTRAL_ROOT + langCode + MOZCENTRAL_PDFJS_DIR +
               fileName + MOZCENTRAL_RAW_FLAG;
     var request = http.get(url, function(response) {
@@ -81,13 +81,13 @@ function downloadLanguageFiles(langCode, callback) {
   });
 }
 
-function downloadL10n() {
+function downloadL10n(root) {
   var i = 0;
   (function next() {
     if (i >= langCodes.length) {
       return;
     }
-    downloadLanguageFiles(langCodes[i++], next);
+    downloadLanguageFiles(root, langCodes[i++], next);
   })();
 }
 
diff --git a/gulpfile.js b/gulpfile.js
index 623be57..87afc01 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -17,10 +17,15 @@
 
 'use strict';
 
+var fs = require('fs');
 var gulp = require('gulp');
 var gutil = require('gulp-util');
+var rimraf = require('rimraf');
 var stream = require('stream');
 
+var BUILD_DIR = 'build/';
+var L10N_DIR = 'l10n/';
+
 require('./make.js');
 
 function createStringSource(filename, content) {
@@ -56,6 +61,13 @@ gulp.task('server', function () {
   server.start();
 });
 
+gulp.task('clean', function(callback) {
+  console.log();
+  console.log('### Cleaning up project builds');
+
+  rimraf(BUILD_DIR, callback);
+});
+
 gulp.task('makefile', function () {
   var makefileContent = 'help:\n\tgulp\n\n';
   var targetsNames = [];
@@ -68,6 +80,18 @@ gulp.task('makefile', function () {
     .pipe(gulp.dest('.'));
 });
 
+gulp.task('importl10n', function() {
+  var locales = require('./external/importL10n/locales.js');
+
+  console.log();
+  console.log('### Importing translations from mozilla-aurora');
+
+  if (!fs.existsSync(L10N_DIR)) {
+    fs.mkdirSync(L10N_DIR);
+  }
+  locales.downloadL10n(L10N_DIR);
+});
+
 // Getting all shelljs registered tasks and register them with gulp
 var gulpContext = false;
 for (var taskName in global.target) {
diff --git a/make.js b/make.js
index db6f42d..561cf9c 100644
--- a/make.js
+++ b/make.js
@@ -1512,11 +1512,7 @@ target.lint = function() {
 // make clean
 //
 target.clean = function() {
-  cd(ROOT_DIR);
-  echo();
-  echo('### Cleaning up project builds');
-
-  rm('-rf', BUILD_DIR);
+  exit(exec('gulp clean'));
 };
 
 //
@@ -1530,17 +1526,5 @@ target.makefile = function () {
 //make importl10n
 //
 target.importl10n = function() {
-  var locales = require('./external/importL10n/locales.js');
-  var LOCAL_L10N_DIR = 'l10n';
-
-  cd(ROOT_DIR);
-  echo();
-  echo('### Importing translations from mozilla-aurora');
-
-  if (!test('-d', LOCAL_L10N_DIR)) {
-    mkdir(LOCAL_L10N_DIR);
-  }
-  cd(LOCAL_L10N_DIR);
-
-  locales.downloadL10n();
+  exit(exec('gulp importl10n'));
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list