-
Notifications
You must be signed in to change notification settings - Fork 43
/
injectLatestProps.js
61 lines (55 loc) · 1.72 KB
/
injectLatestProps.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
53
54
55
56
57
58
59
60
61
const { execSync } = require("child_process");
const findRemoveSync = require("find-remove");
const cpDir = require("copy-dir");
/*
* 1. find and delete any directory named react-native-elements
* 2. find and delete any directory named Props
* 3. clone the react-native-elements(https://github.com/react-native-elements/react-native-elements) repo
* 4. copy Props folder from cloned repo into our project
*/
try {
// Point 1. depth=1 required (to avoid deleting node_modules/react-native-elements)
let result = findRemoveSync(".", {
maxLevel: 1,
dir: "react-native-elements",
});
console.log("✔️ Removed ?: ", result);
// Point 2
result = findRemoveSync("./src/content", { dir: "Props" });
console.log("✔️ Removed ?: ", result);
// Point 3
execSync(
"git clone https://github.com/react-native-elements/react-native-elements --depth=1",
(err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
}
);
console.log("✔️ Cloned react-native-elements");
execSync(
"sed -i '/## Props/,$!d' ./react-native-elements/website/docs/main/*.mdx",
(err, stdout, stderr) => {
if (err) {
// node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
}
);
// Point 4
cpDir.sync(
"./react-native-elements/website/docs/main",
"./src/content/Props"
);
console.log("✔️ Copied Props to src/content/Props");
} catch (err) {
console.error(err);
return;
}