Skip to content

Commit

Permalink
Merge pull request #16678 from jonallengriffin/modules
Browse files Browse the repository at this point in the history
Bug 977366 - Allow make node_modules to use git mirror, r=gaye
  • Loading branch information
Jonathan Griffin committed Mar 5, 2014
2 parents 05337d2 + ad73d76 commit 66101d5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ DESKTOP_SHIMS?=0
GAIA_OPTIMIZE?=0
GAIA_DEV_PIXELS_PER_PX?=1
DOGFOOD?=0
NODE_MODULES_SRC?=modules.tar

# Rocketbar customization
# none - Do not enable rocketbar
Expand Down Expand Up @@ -176,6 +177,10 @@ ifeq ($(DOGFOOD), 1)
GAIA_APP_TARGET=dogfood
endif

ifdef NODE_MODULES_GIT_URL
NODE_MODULES_SRC := git-gaia-node-modules
endif

###############################################################################
# The above rules generate the profile/ folder and all its content. #
# The profile folder content depends on different rules: #
Expand Down Expand Up @@ -684,12 +689,20 @@ endif
NPM_INSTALLED_PROGRAMS = node_modules/.bin/mozilla-download node_modules/.bin/jshint node_modules/.bin/mocha
$(NPM_INSTALLED_PROGRAMS): package.json node_modules

modules.tar:
$(NODE_MODULES_SRC):
ifeq "$(NODE_MODULES_SRC)" "modules.tar"
$(DOWNLOAD_CMD) https://github.com/mozilla-b2g/gaia-node-modules/tarball/master
mv master modules.tar
mv master "$(NODE_MODULES_SRC)"
else
git clone "$(NODE_MODULES_GIT_URL)" "$(NODE_MODULES_SRC)"
endif

node_modules: modules.tar
$(TAR_WILDCARDS) --strip-components 1 -x -m -f modules.tar "mozilla-b2g-gaia-node-modules-*/node_modules"
node_modules: $(NODE_MODULES_SRC)
ifeq "$(NODE_MODULES_SRC)" "modules.tar"
$(TAR_WILDCARDS) --strip-components 1 -x -m -f $(NODE_MODULES_SRC) "mozilla-b2g-gaia-node-modules-*/node_modules"
else
mv $(NODE_MODULES_SRC)/node_modules node_modules
endif
npm install && npm rebuild
@echo "node_modules installed."

Expand Down
41 changes: 41 additions & 0 deletions build/test/integration/build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,47 @@ var AdmZip = require('adm-zip');
var dive = require('dive');
var helper = require('./helper');

suite('Node modules tests', function() {
test('make node_modules from git mirror', function(done) {
rmrf('modules.tar');
rmrf('node_modules');
rmrf('git-gaia-node-modules');
exec('NODE_MODULES_GIT_URL=https://git.mozilla.org/b2g/gaia-node-modules.git make node_modules',
function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);

var modulesTarPath = path.join(process.cwd(), 'git-gaia-node-modules',
'.git');
assert.ok(fs.existsSync(modulesTarPath));

var packageJson = path.join(process.cwd(), 'node_modules',
'marionette-client', 'package.json');
assert.ok(fs.existsSync(packageJson));

done();
});
});

test('make node_modules from github', function(done) {
rmrf('modules.tar');
rmrf('node_modules');
rmrf('git-gaia-node-modules');
exec('make node_modules',
function(error, stdout, stderr) {
helper.checkError(error, stdout, stderr);

var modulesTarPath = path.join(process.cwd(), 'modules.tar');
assert.ok(fs.existsSync(modulesTarPath));

var packageJson = path.join(process.cwd(), 'node_modules',
'marionette-client', 'package.json');
assert.ok(fs.existsSync(packageJson));

done();
});
});
});

suite('Build Integration tests', function() {
var localesDir = 'tmplocales';

Expand Down

0 comments on commit 66101d5

Please sign in to comment.