You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2014/10/01 21:29:58 UTC
git commit: CB-7686 add "npm-link" command to coho
Repository: cordova-coho
Updated Branches:
refs/heads/master 337561696 -> 753e01d40
CB-7686 add "npm-link" command to coho
Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/753e01d4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/753e01d4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/753e01d4
Branch: refs/heads/master
Commit: 753e01d40f2374ccb1f9f400f56936e3ea5dbf72
Parents: 3375616
Author: Marcel Kinard <cm...@gmail.com>
Authored: Wed Oct 1 15:29:12 2014 -0400
Committer: Marcel Kinard <cm...@gmail.com>
Committed: Wed Oct 1 15:29:40 2014 -0400
----------------------------------------------------------------------
src/main.js | 4 +++
src/npm-link.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/753e01d4/src/main.js
----------------------------------------------------------------------
diff --git a/src/main.js b/src/main.js
index 96d2a4a..74f7523 100644
--- a/src/main.js
+++ b/src/main.js
@@ -117,6 +117,10 @@ module.exports = function() {
name: 'for-each',
desc: 'Runs a shell command in each repo.',
entryPoint: lazyRequire('./for-each')
+ }, {
+ name: 'npm-link',
+ desc: 'Does an "npm link" of dependent modules that we own.',
+ entryPoint: lazyRequire('./npm-link')
}
];
var commandMap = {};
http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/753e01d4/src/npm-link.js
----------------------------------------------------------------------
diff --git a/src/npm-link.js b/src/npm-link.js
new file mode 100644
index 0000000..1af0ffc
--- /dev/null
+++ b/src/npm-link.js
@@ -0,0 +1,79 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+var path = require('path');
+var optimist = require('optimist');
+var shelljs = require('shelljs');
+var flagutil = require('./flagutil');
+
+module.exports = function*(argv) {
+ var opt = flagutil.registerHelpFlag(optimist);
+ argv = opt
+ .usage('Does an npm-link of the modules that we publish. Ensures we are testing live versions of our own dependencies instead of the last published version.\n' +
+ '\n' +
+ 'Usage: $0 npm-link')
+ .argv;
+
+ if (argv.h) {
+ optimist.showHelp();
+ process.exit(1);
+ }
+
+ function getPathFromModuleName(moduleName) {
+ if (moduleName == "cordova-lib") {
+ return(moduleName + path.sep + moduleName);
+ } else {
+ return(moduleName);
+ }
+ }
+
+ function cdInto(moduleName) {
+ var myPath = getPathFromModuleName(moduleName);
+ shelljs.pushd(myPath);
+ }
+
+ function cdOutOf() {
+ shelljs.popd();
+ }
+
+ function npmLinkIn(linkedModule, installingModule) {
+ cdInto(installingModule);
+ // 'npm link' will automatically unbuild a non-linked module if it is present,
+ // so don't need to explicitly 'rm -r' it first.
+ shelljs.exec("npm link " + linkedModule);
+ cdOutOf();
+ }
+
+ function npmLinkOut(moduleName) {
+ cdInto(moduleName);
+ shelljs.exec("npm link");
+ cdOutOf();
+ }
+
+ console.log("npm-linking dependent modules");
+
+ npmLinkOut("cordova-js");
+ npmLinkIn("cordova-js", "cordova-lib");
+
+ npmLinkOut("cordova-lib");
+ npmLinkIn("cordova-lib", "cordova-plugman");
+ npmLinkIn("cordova-lib", "cordova-cli");
+
+};
+