Skip to content

Commit

Permalink
refactor(create): depend directly on cordova-create (#489)
Browse files Browse the repository at this point in the history
This will allow us to remove the `cordova.create` stub from
`cordova-lib`.

Moreover it flattens our dependency graph by one level.
  • Loading branch information
raphinesse authored Nov 11, 2019
1 parent 0c40bdb commit fb6bc3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dependencies": {
"configstore": "^4.0.0",
"cordova-common": "^3.1.0",
"cordova-create": "^2.0.0",
"cordova-lib": "^9.0.0",
"editor": "^1.0.0",
"insight": "^0.10.1",
Expand Down
13 changes: 9 additions & 4 deletions spec/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ const path = require('path');
const rewire = require('rewire');
const { events, cordova } = require('cordova-lib');
const telemetry = require('../src/telemetry');
const cli = rewire('../src/cli');

describe('cordova cli', () => {
let logger;
let cli, logger;

beforeEach(() => {
cli = rewire('../src/cli');

// Event registration is currently process-global. Since all jasmine
// tests in a directory run in a single process (and in parallel),
// logging events registered as a result of the "--verbose" flag in
Expand Down Expand Up @@ -116,12 +117,16 @@ describe('cordova cli', () => {

describe('create', () => {
beforeEach(() => {
spyOn(cordova, 'create').and.returnValue(Promise.resolve());
cli.__set__({
cordovaCreate: jasmine.createSpy('cordovaCreate').and.resolveTo()
});
});

it('Test#011 : calls cordova create', () => {
return cli(['node', 'cordova', 'create', 'a', 'b', 'c', '--link-to', 'c:\\personalWWW']).then(() => {
expect(cordova.create).toHaveBeenCalledWith('a', 'b', 'c', jasmine.any(Object), jasmine.any(Object));
expect(cli.__get__('cordovaCreate')).toHaveBeenCalledWith(
'a', 'b', 'c', jasmine.any(Object), jasmine.any(Object)
);
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var CordovaError = cordova_lib.CordovaError;
var cordova = cordova_lib.cordova;
var events = cordova_lib.events;
var logger = require('cordova-common').CordovaLogger.get();
var cordovaCreate = require('cordova-create');
var Configstore = require('configstore');
var conf = new Configstore(pkg.name + '-config');
var editor = require('editor');
Expand Down Expand Up @@ -493,5 +494,5 @@ function create ([_, dir, id, name], args) {
};

}
return cordova.create(dir, id, name, cfg, events || undefined);
return cordovaCreate(dir, id, name, cfg, events || undefined);
}

0 comments on commit fb6bc3e

Please sign in to comment.