-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippetGenerator.js
More file actions
35 lines (28 loc) · 954 Bytes
/
Copy pathsnippetGenerator.js
File metadata and controls
35 lines (28 loc) · 954 Bytes
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
const childProcess = require('child_process');
const fs = require('fs');
const result = childProcess.execSync('find node_modules/react-native-ui-lib/src -name "*api.json"');
const apis = result.toString().trim().split('\n');
const components = apis.map(filePath => {
const file = fs.readFileSync(filePath);
const api = JSON.parse(file.toString());
return api;
});
let output = {};
if (components) {
components.forEach(component => {
const object = {};
const name = component.name;
object.prefix = name.charAt(0).toLowerCase() + name.slice(1);
object.description = component.description;
object.body = component.snippet;
output[component.name] = object;
});
output["UilibImport"] = {
"prefix": "rnuilib",
"description": "Import react-native-ui-lib",
"body": [
"import {$1} from 'react-native-ui-lib';"
]
}
fs.writeFileSync(`snippets/snippets.code-snippets`, JSON.stringify(output));
}