Skip to content

Commit

Permalink
Merge pull request #38 from brodybits/gh-37-patch-release-updates
Browse files Browse the repository at this point in the history
GH-37 patch release updates for 1.3.1
  • Loading branch information
Chris Brody authored Aug 14, 2018
2 parents 70fec9e + 17e21e7 commit 7dca991
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 366 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_js:
- "4"
- "6"
- "8"
- "10"
install:
- "npm install"
script:
Expand Down
6 changes: 5 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ environment:
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"

- nodejs_version: "10"

install:
- ps: Install-Product node $env:nodejs_version
- npm install
Expand All @@ -16,4 +17,7 @@ build: off
test_script:
- node --version
- npm --version
# Solution proposed in https://stackoverflow.com/questions/49256190/how-to-fix-git-sh-setup-file-not-found-in-windows#comment88245403_49256190
# to work around https://github.com/appveyor/ci/issues/2420
- set "PATH=%PATH%;C:\Program Files\Git\mingw64\libexec\git-core"
- npm test
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var path = require('path');
var fs = require('fs');
var CordovaError = require('cordova-common').CordovaError;
var isUrl = require('is-url');
var isGitUrl = require('is-git-url');
var hostedGitInfo = require('hosted-git-info');

/*
Expand Down Expand Up @@ -144,7 +145,7 @@ function getJsonDiff (obj1, obj2) {
* get the moduleID of the installed module.
*
* @param {String} target target that was passed into cordova-fetch.
* can be moduleID, moduleID@version or gitURL
* can be moduleID, moduleID@version, gitURL or relative path (file:relative/path)
*
* @return {String} ID moduleID without version.
*/
Expand All @@ -154,7 +155,7 @@ function trimID (target) {
var gitInfo = hostedGitInfo.fromUrl(target);
if (gitInfo) {
target = gitInfo.project;
} else if (isUrl(target)) {
} else if (isUrl(target) || isGitUrl(target)) {
// strip away .git and everything that follows
var strippedTarget = target.split('.git');
var re = /.*\/(.*)/;
Expand All @@ -165,6 +166,11 @@ function trimID (target) {
}

// If local path exists, try to get plugin id from package.json or set target to final directory
if (target.startsWith('file:')) {
// If target starts with file: prefix, strip it
target = target.substring(5);
}

if (fs.existsSync(target)) {
var pluginId;
var pkgJsonPath = path.join(target, 'package.json');
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/apache/cordova-lib"
"url": "https://github.com/apache/cordova-fetch"
},
"keywords": [
"cordova",
Expand All @@ -21,26 +21,28 @@
"email": "dev@cordova.apache.org"
},
"dependencies": {
"cordova-common": "^2.2.0",
"cordova-common": "^2.2.5",
"dependency-ls": "^1.1.0",
"hosted-git-info": "^2.5.0",
"is-url": "^1.2.1",
"is-git-url": "^1.0.0",
"q": "^1.4.1",
"shelljs": "^0.7.0"
},
"devDependencies": {
"eslint": "^3.19.0",
"eslint": "^4.19.1",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-standard": "^3.1.0",
"fs-extra": "^4.0.3",
"jasmine": "^2.4.1"
},
"scripts": {
"test": "npm run eslint && npm run jasmine",
"eslint": "eslint index.js spec/fetch.spec.js",
"eslint": "eslint .",
"jasmine": "jasmine spec/fetch.spec.js spec/fetch-unit.spec.js"
},
"engines": {
Expand Down
50 changes: 15 additions & 35 deletions spec/fetch-unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,35 @@ describe('unit tests for index.js', function () {
spyOn(fs, 'existsSync').and.returnValue(false);
});

it('npm install should be called with production flag (default)', function (done) {
var opts = { cwd: 'some/path', production: true, save: true};
fetch('platform', 'tmpDir', opts)
it('npm install should be called with production flag (default)', function () {
var opts = { cwd: 'some/path', production: true, save: true };
return fetch('platform', 'tmpDir', opts)
.then(function (result) {
expect(superspawn.spawn).toHaveBeenCalledWith('npm', jasmine.stringMatching(/production/), jasmine.any(Object));
})
.fail(function (err) {
console.error(err);
expect(err).toBeUndefined();
})
.fin(done);
});
});

it('save-exact should be true if passed in', function (done) {
it('save-exact should be true if passed in', function () {
var opts = { cwd: 'some/path', save_exact: true };
fetch('platform', 'tmpDir', opts)
return fetch('platform', 'tmpDir', opts)
.then(function (result) {
expect(superspawn.spawn).toHaveBeenCalledWith('npm', jasmine.stringMatching(/save-exact/), jasmine.any(Object));
})
.fail(function (err) {
console.error(err);
expect(err).toBeUndefined();
})
.fin(done);
});
});

it('noprod should turn production off', function (done) {
var opts = { cwd: 'some/path', production: false};
fetch('platform', 'tmpDir', opts)
it('noprod should turn production off', function () {
var opts = { cwd: 'some/path', production: false };
return fetch('platform', 'tmpDir', opts)
.then(function (result) {
expect(superspawn.spawn).not.toHaveBeenCalledWith('npm', jasmine.stringMatching(/production/), jasmine.any(Object));
})
.fail(function (err) {
console.error(err);
expect(err).toBeUndefined();
})
.fin(done);
});
});

it('when save is false, no-save flag should be passed through', function (done) {
var opts = { cwd: 'some/path', production: true, save: false};
fetch('platform', 'tmpDir', opts)
it('when save is false, no-save flag should be passed through', function () {
var opts = { cwd: 'some/path', production: true, save: false };
return fetch('platform', 'tmpDir', opts)
.then(function (result) {
expect(superspawn.spawn).toHaveBeenCalledWith('npm', jasmine.stringMatching(/--no-save/), jasmine.any(Object));
})
.fail(function (err) {
console.error(err);
expect(err).toBeUndefined();
})
.fin(done);
});
});
});
Loading

0 comments on commit 7dca991

Please sign in to comment.