Skip to content

Commit df4f9d5

Browse files
author
radeva
authored
Merge pull request #104 from EddyVerbruggen/master
Play nice with nativescript-telerik-ui-pro. Fixes #50
2 parents 2cd4b3d + 7d67f5f commit df4f9d5

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"plugin.tscwatch": "npm run tsc -- -w",
2929
"demo.ios": "npm i && npm run tsc && cd ../demo && tns run ios --syncAllFiles",
3030
"demo.android": "npm i && npm run tsc && cd ../demo && tns run android --syncAllFiles",
31-
"clean": "rm -rf node_modules && cd ../demo && rm -rf hooks node_modules platforms && cd ../src && npm run plugin.link"
31+
"clean": "rm -rf node_modules && cd ../demo && rm -rf hooks node_modules platforms && cd ../src && npm run plugin.link",
32+
"postinstall": "node scripts/require-nativescript-telerik-ui.js"
3233
},
3334
"keywords": [
3435
"NativeScript",
@@ -44,13 +45,13 @@
4445
"homepage": "https://github.com/NativeScript/nativescript-imagepicker",
4546
"readmeFilename": "README.md",
4647
"devDependencies": {
48+
"nativescript-telerik-ui": "^3.0.0",
4749
"tns-core-modules": "^3.1.0",
4850
"tns-platform-declarations": "^3.0.0",
4951
"typescript": "~2.3.0",
5052
"tslint": "~5.4.3"
5153
},
5254
"dependencies": {
53-
"nativescript-telerik-ui": "^3.0.0",
5455
"nativescript-permissions": "~1.2.3"
5556
},
5657
"bootstrapper": "nativescript-plugin-seed"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var path = require("path"),
2+
projectPackageJsonFilename = path.join(__dirname, "..", "..", "..", "package.json"),
3+
projectPackageJson;
4+
5+
// ignore the remainder of the script if for some reason no package.json exists
6+
try { projectPackageJson = require(projectPackageJsonFilename); } catch (ignore) { return; };
7+
8+
// check if either nativescript-telerik-ui or nativescript-telerik-ui-pro are installed
9+
var telerikui = projectPackageJson.dependencies["nativescript-telerik-ui"];
10+
var telerikuipro = projectPackageJson.dependencies["nativescript-telerik-ui-pro"];
11+
12+
// if neither are installed, add nativescript-telerik-ui to the project package.json as a dependency,
13+
// so the user can always later decide to upgrade to nativescript-telerik-ui-pro.
14+
if (telerikui === undefined && telerikuipro === undefined) {
15+
16+
// we want to install the same version this plugin is tested with, so grab it from the devDependencies.
17+
var pluginPackageJson = require(path.join(__dirname, "..", "package.json"));
18+
var telerikuiversion = pluginPackageJson.devDependencies["nativescript-telerik-ui"];
19+
20+
// give the user a bit of feedback as installing this dependency take a while to complete.
21+
console.log("The nativescript-imagepicker plugin requires nativescript-telerik-ui. Please wait while it's being added to your project...");
22+
require('child_process').execSync('npm i --save nativescript-telerik-ui@' + telerikuiversion, { cwd: path.join(__dirname, "..", "..")});
23+
console.log("nativescript-telerik-ui@" + telerikuiversion + " has been successfully installed and was added to your app's package.json.");
24+
}

0 commit comments

Comments
 (0)