forked from Gruntfuggly/todo-tree
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildCodiconNames.js
More file actions
executable file
·48 lines (36 loc) · 1.34 KB
/
buildCodiconNames.js
File metadata and controls
executable file
·48 lines (36 loc) · 1.34 KB
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
#!/usr/bin/env node
var fs = require( 'fs' );
var path = require( 'path' );
var cp = require( "child_process" );
var codiconMappingUrl = "https://raw.githubusercontent.com/microsoft/vscode-codicons/main/src/template/mapping.json";
var outputPath = path.join( __dirname, "src/codiconNames.js" );
var raw = cp.execFileSync( "curl", [ "-fsSL", codiconMappingUrl ], { encoding: "utf8" } );
var mappings = JSON.parse( raw );
if( !mappings || Array.isArray( mappings ) || typeof mappings !== "object" )
{
throw new Error( "codicon mapping: object required" );
}
var names = [];
Object.keys( mappings ).forEach( function( codepoint )
{
var aliases = mappings[ codepoint ];
if( Array.isArray( aliases ) !== true )
{
throw new Error( "codicon mapping " + codepoint + ": alias array required" );
}
aliases.forEach( function( alias )
{
if( typeof alias !== "string" || alias.length === 0 )
{
throw new Error( "codicon mapping " + codepoint + ": non-empty alias required" );
}
names.push( alias );
} );
} );
names = Array.from( new Set( names ) ).sort();
var output = "module.exports = " + JSON.stringify( names, null, 2 ) + ";\n";
if( fs.existsSync( outputPath ) && fs.readFileSync( outputPath, "utf8" ) === output )
{
process.exit( 0 );
}
fs.writeFileSync( outputPath, output );