Skip to content
Permalink
Browse files
CB-12765: default app cordova-app-hello-world is now treated like a t…
…emplate
  • Loading branch information
stevengill committed May 4, 2017
1 parent 37d329d commit a60bfa309115dd6f7079dd6af3165e8214d96a08
Showing 2 changed files with 24 additions and 9 deletions.
@@ -133,7 +133,8 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents) {

if (!cfg.lib.www.url) {
try {
cfg.lib.www.url = require('cordova-app-hello-world').dirname;
cfg.lib.www.url = require.resolve('cordova-app-hello-world');
cfg.lib.www.template = true;
} catch (e) {
// Falling back on npm@2 path hierarchy
// TODO: Remove fallback after cordova-app-hello-world release
@@ -229,7 +230,7 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents) {
// Delete cached require incase one exists
delete require.cache[require.resolve(input_directory)];
var templatePkg = require(input_directory);
if (templatePkg && templatePkg.dirname){
if (templatePkg && templatePkg.dirname) {
import_from_path = templatePkg.dirname;
isSubDir = true;
}
@@ -255,7 +256,6 @@ module.exports = function(dir, optionalId, optionalName, cfg, extEvents) {
paths.hooks = path.join(require('cordova-app-hello-world').dirname, 'hooks');

// ToDo: get stock package.json if template does not contain package.json;

var dirAlreadyExisted = fs.existsSync(dir);
if (!dirAlreadyExisted) {
fs.mkdirSync(dir);
@@ -109,7 +109,6 @@ describe('cordova create checks for valid-identifier', function() {


describe('create end-to-end', function() {
//this.timeout(240000);

beforeEach(function() {
shell.rm('-rf', project);
@@ -203,9 +202,25 @@ describe('create end-to-end', function() {
var results;
events.on('results', function(res) { results = res; });

it('should successfully run without template and use default hello-world app', function(done) {
// Create a real project with no template
// use default cordova-app-hello-world app
return create(project, appId, appName, {}, events)
.then(checkProject)
.then(function() {
delete require.cache[require.resolve(path.join(project, 'package.json'))];
var pkgJson = require(path.join(project, 'package.json'));
//confirm default hello world app copies over package.json and it matched appId
expect(pkgJson.name).toEqual(appId);
}).fail(function(err) {
console.log(err && err.stack);
expect(err).toBeUndefined();
})
.fin(done);
}, 60000);

it('should successfully run with Git URL', function(done) {
// Call cordova create with no args, should return help.)
// Create a real project
// Create a real project with gitURL as template
return create(project, appId, appName, configGit, events)
.then(checkProject)
.fail(function(err) {
@@ -217,9 +232,9 @@ describe('create end-to-end', function() {

it('should successfully run with NPM package and not use old cache of template on second create', function(done) {
var templatePkgJsonPath = path.join(global_config_path, 'node_modules', 'phonegap-template-vue-f7-tabs', 'package.json');
// Call cordova create with no args, should return help.
// Create a real project
//uses phonegap-template-vue-f7-tabs
// Create a real project with npm module as template
// tests cache clearing of npm template
// uses phonegap-template-vue-f7-tabs
return create(project, appId, appName, configNPMold)
.then(checkProject)
.then(function() {

0 comments on commit a60bfa3

Please sign in to comment.