CB-12765: default app cordova-app-hello-world is now treated like a template
diff --git a/index.js b/index.js
index d29b8a4..827f158 100644
--- a/index.js
+++ b/index.js
@@ -133,7 +133,8 @@
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 @@
// 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 @@
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);
diff --git a/spec/create.spec.js b/spec/create.spec.js
index 407ee46..f8db27e 100644
--- a/spec/create.spec.js
+++ b/spec/create.spec.js
@@ -109,7 +109,6 @@
describe('create end-to-end', function() {
- //this.timeout(240000);
beforeEach(function() {
shell.rm('-rf', project);
@@ -203,9 +202,25 @@
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 @@
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() {