You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2018/12/04 13:52:44 UTC
[cordova-lib] branch master updated: Fix crash in `cordova
requirements` due to an unbound function (#741)
This is an automated email from the ASF dual-hosted git repository.
brodybits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-lib.git
The following commit(s) were added to refs/heads/master by this push:
new b9ad92a Fix crash in `cordova requirements` due to an unbound function (#741)
b9ad92a is described below
commit b9ad92a6693c2fe977309d17449fa95949c1f7c3
Author: Ran Benita <ra...@gmail.com>
AuthorDate: Tue Dec 4 15:52:39 2018 +0200
Fix crash in `cordova requirements` due to an unbound function (#741)
Functions in utils.js expect to be called with `this` bound to the
module. So this call crashed with an error
this.isCordova is not a function
Fixes #740.
---
spec/cordova/requirements.spec.js | 40 +++++++++++++++++++++++++++++++++++++++
src/cordova/requirements.js | 4 ++--
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/spec/cordova/requirements.spec.js b/spec/cordova/requirements.spec.js
new file mode 100644
index 0000000..d8ed8df
--- /dev/null
+++ b/spec/cordova/requirements.spec.js
@@ -0,0 +1,40 @@
+/**
+ 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 rewire = require('rewire');
+var util = require('../../src/cordova/util');
+var requirements = rewire('../../src/cordova/requirements');
+
+var project_dir = '/some/path';
+
+describe('cordova/requirements', function () {
+ beforeEach(function () {
+ spyOn(util, 'isCordova').and.returnValue(project_dir);
+ });
+
+ describe('main method', function () {
+ it('should fail if no platforms are added', function () {
+ return requirements([]).then(function () {
+ }, function (err) {
+ expect(err).toEqual(jasmine.any(Error));
+ expect(err.message).toMatch('No platforms added');
+ });
+ });
+ });
+});
diff --git a/src/cordova/requirements.js b/src/cordova/requirements.js
index bc7dd6e..4ee038a 100644
--- a/src/cordova/requirements.js
+++ b/src/cordova/requirements.js
@@ -18,7 +18,7 @@
*/
const { object: zipObject } = require('underscore');
-const { preProcessOptions } = require('./util');
+const cordova_util = require('./util');
const { CordovaError } = require('cordova-common');
const knownPlatforms = require('../platforms/platforms');
@@ -33,7 +33,7 @@ const knownPlatforms = require('../platforms/platforms');
*/
module.exports = function check_reqs (platforms) {
return Promise.resolve().then(() => {
- const normalizedPlatforms = preProcessOptions(platforms).platforms;
+ const normalizedPlatforms = cordova_util.preProcessOptions(platforms).platforms;
return Promise.all(
normalizedPlatforms.map(getPlatformRequirementsOrError)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org