-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathutils.js
More file actions
28 lines (24 loc) · 625 Bytes
/
Copy pathutils.js
File metadata and controls
28 lines (24 loc) · 625 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
const t = require('@babel/types');
function getName(asset, type, ...rest) {
return (
'$' +
t.toIdentifier(asset.id) +
'$' +
type +
(rest.length
? '$' +
rest
.map(name => (name === 'default' ? name : t.toIdentifier(name)))
.join('$')
: '')
);
}
function getIdentifier(asset, type, ...rest) {
return t.identifier(getName(asset, type, ...rest));
}
function getExportIdentifier(asset, name) {
return getIdentifier(asset, 'export', name);
}
exports.getName = getName;
exports.getIdentifier = getIdentifier;
exports.getExportIdentifier = getExportIdentifier;