-
Notifications
You must be signed in to change notification settings - Fork 35
/
built-init.js
42 lines (38 loc) · 1.13 KB
/
built-init.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
const shellJS = require('shelljs');
const fs = require('fs');
const { REPO_BRANCH, REPO_LINK } = require('./constants');
const fsExtra = require('fs-extra');
const URL = REPO_LINK + '.git';
const path = __dirname + '/src/nb/NativeBase';
try {
if (fs.existsSync(path)) {
shellJS.cd(path);
shellJS.exec('git checkout ' + REPO_BRANCH);
shellJS.exec('git pull origin ' + REPO_BRANCH);
}
else{
const PARENTFOLDER = __dirname +'/src/nb';
shellJS.cd(PARENTFOLDER);
shellJS.exec('git clone ' + URL);
}
const componentsPath = __dirname + '/src/nb/NativeBase/example/storybook/stories/components';
const basicComponentsPath = __dirname +'/src/nb/components';
fs.rmdir(basicComponentsPath, { recursive: true }, (err) => {
if (err) {
throw err;
}
console.log(`deleted!`);
fs.mkdir(basicComponentsPath, (err) => {
if (err) throw err;
fsExtra.copy(componentsPath, basicComponentsPath, (err) => {
if(err){
console.log("Error occurred");
return;
}
console.log('Copy completed');
});
})
});
} catch(err) {
console.error(err)
}