diff --git a/package.json b/package.json index 8eef7aba44..bc5ae5f4c0 100644 --- a/package.json +++ b/package.json @@ -107,6 +107,7 @@ "@types/uuid": "^3.4.0", "@types/winston": "^2.2.0", "prettier": "~1.7.0", + "@types/xml2js": "^0.4.0", "tslint-config-prettier": "^1.1.0", "tslint-react": "~3.0.0" } diff --git a/script/generate-octicons b/script/generate-octicons.ts similarity index 79% rename from script/generate-octicons rename to script/generate-octicons.ts index fa09963ae7..93eff61bd5 100644 --- a/script/generate-octicons +++ b/script/generate-octicons.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /* generate-octicons * * Utility script for generating a strongly typed representation of all @@ -9,11 +7,11 @@ 'use strict' -const fs = require('fs') -const process = require('process') -const xml2js = require('xml2js') -const path = require('path') -const toCamelCase = require('to-camel-case') +import fs = require('fs') +import process = require('process') +import xml2js = require('xml2js') +import path = require('path') +import toCamelCase = require('to-camel-case') const filePath = path.resolve( __dirname, @@ -26,7 +24,16 @@ const filePath = path.resolve( const file = fs.readFileSync(filePath) -xml2js.parseString(file, function(err, result) { +interface XML2JSResult { + svg: { symbol: ReadonlyArray } +} +interface XML2JSNode { + $: { [key: string]: string } + path: ReadonlyArray + +} + +xml2js.parseString(file, function(err, result: XML2JSResult) { const viewBoxRe = /0 0 (\d+) (\d+)/ const out = fs.createWriteStream( path.resolve(__dirname, '../app/src/ui/octicons/octicons.generated.ts')