forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddEjectScript.js
52 lines (43 loc) · 1.42 KB
/
addEjectScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var fs = require('fs');
var util = require('util');
var path = require('path');
var printMessage = require('print-message');
fs.copy = function (src, dst, cb) {
console.warn('[Deprecated] See https://github.com/coolaj86/utile-fs');
function copy(err) {
var is
, os
;
if (!err) {
return cb(new Error("File " + dst + " exists."));
}
fs.stat(src, function (err) {
if (err) {
return cb(err);
}
is = fs.createReadStream(src);
os = fs.createWriteStream(dst);
util.pump(is, os, cb);
});
}
fs.stat(dst, copy);
};
var projectPackage = require(path.join(__dirname, '..', '..', 'package.json'));
if(!projectPackage.scripts) {
projectPackage.scripts = {};
}
projectPackage.scripts['eject-native-base'] = 'node node_modules/native-base/ejectTheme.js';
try {
fs.writeFileSync(path.join(__dirname, '..', '..', 'package.json'), JSON.stringify(projectPackage, null, 2));
printMessage([
'NativeBase 2.0 has been succesfully installed!',
'Run `npm run eject-native-base` to copy over theme config and variables.',
'Head over to the docs for detailed information on how to make changes to the theme.',
], {
color: 'yellow',
borderColor: 'green',
});
} catch(err) {
console.log('Error: ' + err);
console.log('There was some error adding the eject script to your package.json. \nRefer http://docs.nativebase.io/docs/customize/SetUp.html for theming')
}