You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2015/03/26 15:39:37 UTC
cordova-lib git commit: CB-8286 Fix regression from e70432f2: Never
want to link to app-hello-world
Repository: cordova-lib
Updated Branches:
refs/heads/master 6ba6db365 -> cc596a37d
CB-8286 Fix regression from e70432f2: Never want to link to app-hello-world
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/cc596a37
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/cc596a37
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/cc596a37
Branch: refs/heads/master
Commit: cc596a37d77a92665292a5370d660a898217e0cb
Parents: 6ba6db3
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Mar 26 10:34:31 2015 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Mar 26 10:38:49 2015 -0400
----------------------------------------------------------------------
cordova-lib/src/cordova/create.js | 59 +++++++++++++++-------------------
1 file changed, 26 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/cc596a37/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index c0f0a3a..c6538e4 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -166,6 +166,7 @@ function create(dir, optionalId, optionalName, cfg) {
if (fs.existsSync(path.join(paths.root, 'config.xml'))) {
paths.configXml = path.join(paths.root, 'config.xml');
+ paths.configXmlLinkable = true;
} else {
paths.configXml = path.join(__dirname, '..', '..', 'node_modules', 'cordova-app-hello-world', 'config.xml');
}
@@ -176,6 +177,7 @@ function create(dir, optionalId, optionalName, cfg) {
}
if (fs.existsSync(path.join(paths.root, 'hooks'))) {
paths.hooks = path.join(paths.root, 'hooks');
+ paths.hooksLinkable = true;
} else {
paths.hooks = path.join(__dirname, '..', '..', 'node_modules', 'cordova-app-hello-world', 'hooks');
}
@@ -185,45 +187,36 @@ function create(dir, optionalId, optionalName, cfg) {
fs.mkdirSync(dir);
}
- if (!!cfg.lib.www.link) {
- // symlink
- try {
- fs.symlinkSync(paths.www, path.join(dir, 'www'), 'dir');
- if (paths.merges) {
- fs.symlinkSync(paths.merges, path.join(dir, 'merges'), 'dir');
- }
- if (paths.hooks) {
- fs.symlinkSync(paths.hooks, path.join(dir, 'hooks'), 'dir');
+ var tryToLink = !!cfg.lib.www.link;
+ function copyOrLink(src, dst, linkable) {
+ if (src) {
+ if (tryToLink && linkable) {
+ fs.symlinkSync(src, dst, 'dir');
+ } else {
+ shell.mkdir(dst);
+ shell.cp('-R', path.join(src, '*'), dst);
}
- if (paths.configXml) {
+ }
+ }
+ try {
+ copyOrLink(paths.www, path.join(dir, 'www'), true);
+ copyOrLink(paths.merges, path.join(dir, 'merges'), true);
+ copyOrLink(paths.hooks, path.join(dir, 'hooks'), paths.hooksLinkable);
+ if (paths.configXml) {
+ if (tryToLink && paths.configXmlLinkable) {
fs.symlinkSync(paths.configXml, path.join(dir, 'config.xml'));
+ } else {
+ shell.cp(paths.configXml, path.join(dir, 'config.xml'));
}
- } catch (e) {
- if (!dirAlreadyExisted) {
- fs.rmdirSync(dir);
- }
- if (process.platform.slice(0, 3) == 'win' && e.code == 'EPERM') {
- throw new CordovaError('Symlinks on Windows require Administrator privileges');
- }
- throw e;
- }
- } else {
- // copy
- shell.mkdir(path.join(dir, 'www'));
- shell.cp('-R', path.join(paths.www, '*'), path.join(dir, 'www'));
-
- if (paths.merges) {
- shell.mkdir(path.join(dir, 'merges'));
- shell.cp('-R', path.join(paths.merges, '*'), path.join(dir, 'merges'));
}
- if (paths.hooks) {
- shell.mkdir(path.join(dir, 'hooks'));
- shell.cp('-R', path.join(paths.hooks, '*'), path.join(dir, 'hooks'));
+ } catch (e) {
+ if (!dirAlreadyExisted) {
+ shell.rm('-rf', dir);
}
- if (paths.configXml) {
- shell.cp(paths.configXml, path.join(dir, 'config.xml'));
+ if (process.platform.slice(0, 3) == 'win' && e.code == 'EPERM') {
+ throw new CordovaError('Symlinks on Windows require Administrator privileges');
}
-
+ throw e;
}
// Create basic project structure.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org