You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/09/17 00:17:01 UTC
[10/12] cordova-browser git commit: returning promises, not booleans,
making scripts testable
returning promises, not booleans, making scripts testable
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/a6c388ab
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/a6c388ab
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/a6c388ab
Branch: refs/heads/master
Commit: a6c388abf70724282b85118cc6ce3e8ba9333c55
Parents: 0847275
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Wed Sep 16 14:55:46 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Wed Sep 16 14:55:46 2015 -0700
----------------------------------------------------------------------
bin/create | 2 +-
bin/lib/check_reqs.js | 4 ++-
bin/lib/create.js | 6 +++-
bin/templates/project/cordova/build | 3 +-
bin/templates/project/cordova/lib/build.js | 48 +++++++++++++------------
5 files changed, 36 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/a6c388ab/bin/create
----------------------------------------------------------------------
diff --git a/bin/create b/bin/create
index 5b59ad8..b035022 100755
--- a/bin/create
+++ b/bin/create
@@ -31,5 +31,5 @@ if(args.length < 3 || (args[2] == '--help' || args[2] == '/?' || args[2] == '-h'
console.log(' <project_name>: Project name');
process.exit(1);
} else {
- create.createProject(args[2], args[3], args[4], args[5]);
+ create.createProject(args[2], args[3], args[4], args[5]).done();
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/a6c388ab/bin/lib/check_reqs.js
----------------------------------------------------------------------
diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js
index b264c41..720d7aa 100644
--- a/bin/lib/check_reqs.js
+++ b/bin/lib/check_reqs.js
@@ -21,6 +21,8 @@ under the License.
//add methods as we determine what are the requirements
+var Q = require('q');
+
module.exports.run = function() {
- return true;
+ return Q.resolve();
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/a6c388ab/bin/lib/create.js
----------------------------------------------------------------------
diff --git a/bin/lib/create.js b/bin/lib/create.js
index 71986c1..9b6e0ff 100644
--- a/bin/lib/create.js
+++ b/bin/lib/create.js
@@ -21,12 +21,14 @@
var fs = require('fs'),
shjs = require('shelljs'),
+ Q = require ('q'),
args = process.argv,
path = require('path'),
ROOT = path.join(__dirname, '..', '..'),
check_reqs = require('./check_reqs');
-exports.createProject = function(project_path,package_name,project_name){
+module.exports.createProject = function(project_path,package_name,project_name){
+
var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8');
// Set default values for path, package and name
@@ -76,4 +78,6 @@ exports.createProject = function(project_path,package_name,project_name){
].forEach(function(f) {
shjs.chmod(755, path.join(project_path, 'cordova', f));
});
+
+ return Q.resolve();
};
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/a6c388ab/bin/templates/project/cordova/build
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/build b/bin/templates/project/cordova/build
index 64b68f4..e867ab1 100755
--- a/bin/templates/project/cordova/build
+++ b/bin/templates/project/cordova/build
@@ -29,5 +29,6 @@ if ( args[2] == '--help' || args[2] == '/?' || args[2] == '-h' || args[2] == '/h
build.help();
process.exit(0);
} else {
- build.buildProject();
+
+ build.run();
}
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/a6c388ab/bin/templates/project/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/build.js b/bin/templates/project/cordova/lib/build.js
index e46178c..fde7519 100644
--- a/bin/templates/project/cordova/lib/build.js
+++ b/bin/templates/project/cordova/lib/build.js
@@ -19,42 +19,44 @@
* under the License.
*/
-var path = require('path'),
- fs = require('fs'),
- clean = require('./clean'),
- shjs = require('shelljs'),
- zip = require('adm-zip'),
+var path = require('path'),
+ fs = require('fs'),
+ shjs = require('shelljs'),
+ zip = require('adm-zip'),
+ Q = require('q'),
+ clean = require('./clean'),
check_reqs = require('./check_reqs'),
platformWwwDir = path.join('platforms', 'browser', 'www'),
platformBuildDir = path.join('platforms', 'browser', 'build'),
packageFile = path.join(platformBuildDir, 'package.zip');
/**
- * buildProject
+ * run
* Creates a zip file int platform/build folder
*/
-exports.buildProject = function(){
+module.exports.run = function(){
- // Check that requirements are (stil) met
- if (!check_reqs.run()) {
- console.error('Please make sure you meet the software requirements in order to build a browser cordova project');
- process.exit(2);
- }
-
- clean.cleanProject(); // remove old build result
+ return check_reqs.run()
+ .then(function(){
+ return clean.cleanProject();
+ },
+ function checkReqsError(err){
+ console.error('Please make sure you meet the software requirements in order to build a browser cordova project');
+ })
+ .then(function(){
- if (!fs.existsSync(platformBuildDir)) {
- fs.mkdirSync(platformBuildDir);
- }
+ if (!fs.existsSync(platformBuildDir)) {
+ fs.mkdirSync(platformBuildDir);
+ }
- // add the project to a zipfile
- var zipFile = zip();
- zipFile.addLocalFolder(platformWwwDir, '.');
- zipFile.writeZip(packageFile);
+ // add the project to a zipfile
+ var zipFile = zip();
+ zipFile.addLocalFolder(platformWwwDir, '.');
+ zipFile.writeZip(packageFile);
- console.log('Browser packaged app built in '+ packageFile);
+ return Q.resolve();
- process.exit(0);
+ });
};
module.exports.help = function() {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org