-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspect.js
More file actions
executable file
·34 lines (31 loc) · 872 Bytes
/
inspect.js
File metadata and controls
executable file
·34 lines (31 loc) · 872 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
#!/usr/bin/env node
const highlight = require('cli-highlight').highlight;
const fs = require('fs');
const args = process.argv.slice(2);
const logJS = log => console.log(
highlight(
log,
{
language: 'javascript',
ignoreIllegals: true
}
)
);
if (args.length === 2) {
const requestedModule = require(`./libs/constants/${args[0]}`);
const constant = requestedModule[args[1]];
const output = `
{
type: '${constant.type}',
method: '${constant.method}',
key: '${constant.key}',
required: ${JSON.stringify(constant.required)}
}
import { ${args[1]} } from 'atomic-canvas/libs/constants/${args[0]}';
`;
logJS(output);
} else if (args.length === 1) {
logJS(fs.readFileSync(`./src/constants/${args[0]}.js`, 'utf8'));
} else {
fs.readdirSync('./src/constants').forEach(file => console.log(file.replace('.js', '')));
}