11'use strict' ;
22
3- require ( 'node-define' ) ;
4- const fs = require ( 'fs' ) ;
5- const util = require ( 'util' ) ;
6- const fetch = require ( 'node-fetch' ) ;
3+ import fs from 'fs' ;
4+ import util from 'util' ;
5+ import fetch from 'node-fetch' ;
76
87const mkdir = util . promisify ( fs . mkdir ) ;
98const writeFile = util . promisify ( fs . writeFile ) ;
@@ -14,11 +13,11 @@ const repo = 'web-scrobbler';
1413const rawContentUrl = `https://raw.githubusercontent.com/${ owner } /${ repo } ` ;
1514
1615const resDir = 'resources' ;
17- const moduleFile = 'connectors.js ' ;
16+ const moduleFile = 'connectors.ts ' ;
1817const listFile = `${ resDir } /connectors.json` ;
1918
20- async function main ( args ) {
21- const latestTag = args [ 2 ] ;
19+ async function main ( args : string [ ] ) {
20+ const latestTag = args . at ( - 1 ) ;
2221
2322 if ( ! latestTag ) {
2423 console . error ( 'You must provide version as an argument' )
@@ -54,7 +53,7 @@ async function downloadModule(tagName) {
5453}
5554
5655async function dumpConnectors ( ) {
57- const connectors = require ( `./${ moduleFile } ` ) ;
56+ const connectors = ( await import ( `./${ moduleFile } ` ) ) . default as any [ ] ;
5857
5958 const labelArray = connectors . map ( ( entry ) => entry . label ) ;
6059 const contents = JSON . stringify ( labelArray , null , 2 ) ;
@@ -68,7 +67,7 @@ async function dumpConnectors() {
6867}
6968
7069function getModuleUrl ( tagName ) {
71- return `${ rawContentUrl } /${ tagName } /src/core/connectors.js ` ;
70+ return `${ rawContentUrl } /${ tagName } /src/core/connectors.ts ` ;
7271}
7372
7473main ( process . argv ) ;
0 commit comments