This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added post install script. Added post install script to resolve different versions of file and file transfer plugin for different cordova versions. * Refactored a few lines. * Replaced exec method with sync version and added more output to the script. * Fixed logic: no need to install anything if plugin is present. Fixed versions of compatible plugins. * Fixed formatting. * Added support for phonegap cli. Wrapped some functions in try..catch blocks. * Fixed formatting. * Renamed folder.
- Loading branch information
1 parent
f66839f
commit 131c19a
Showing
3 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module.exports = function (ctx) { | ||
var execSync = require('child_process').execSync; | ||
var Q = ctx.requireCordovaModule('q'); | ||
var deferral = new Q.defer(); | ||
|
||
var cordovaCLI = "cordova"; | ||
try { | ||
execSync(cordovaCLI); | ||
} catch (e) { | ||
try { | ||
cordovaCLI = "phonegap"; | ||
execSync(cordovaCLI); | ||
} catch (e) { | ||
deferral.reject("An error occured. Please ensure that either the Cordova or PhoneGap CLI is installed."); | ||
} | ||
} | ||
|
||
console.log("Detecting cordova version..."); | ||
var cordovaVersion = ctx.opts.cordova.version; | ||
console.log("Cordova version is " + cordovaVersion); | ||
|
||
var plugins = execSync(cordovaCLI + ' plugin ls'); | ||
if (!plugins.includes('cordova-plugin-file-transfer')) { | ||
if (parseFloat(cordovaVersion) < 6.3) { | ||
if (!plugins.includes('cordova-plugin-file')) { | ||
console.log("Installing the compatible version of file plugin... "); | ||
execSync(cordovaCLI + ' plugin add [email protected]'); | ||
} | ||
console.log("Installing the compatible version of file transfer plugin... "); | ||
execSync(cordovaCLI + ' plugin add [email protected]'); | ||
} else { | ||
try { | ||
console.log("Installing the latest version of file-transfer plugin... "); | ||
execSync(cordovaCLI + ' plugin add cordova-plugin-file-transfer@latest'); | ||
} catch (e) { | ||
console.log('The version of file plugin appears to be incompatible with the latest file transfer version. Installing compatible version of file transfer.... '); | ||
execSync(cordovaCLI + ' plugin add [email protected]'); | ||
} | ||
} | ||
} | ||
if (!plugins.includes('cordova-plugin-zip')) { | ||
execSync(cordovaCLI + ' plugin add cordova-plugin-zip'); | ||
} | ||
deferral.resolve(); | ||
|
||
return deferral.promise; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters