Skip to content

Commit

Permalink
Update build script (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored Feb 21, 2024
1 parent ce42309 commit 8314faf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
"node": ">=18"
},
"scripts": {
"test": "xo && ava && tsd",
"test": "npm run build && xo && ava && tsd",
"prepare": "npm run build",
"update": "node scripts/update.mjs",
"update:browser": "node scripts/update.mjs --environment=browser",
"update:builtin": "node scripts/update.mjs --environment=builtin",
"update:nodeBuiltin": "node scripts/update.mjs --environment=nodeBuiltin",
"update:worker": "node scripts/update.mjs --environment=worker",
"update:shelljs": "node scripts/update.mjs --environment=shelljs",
"build": "run-s build:data build:types",
"build": "run-p \"build:*\"",
"build:data": "node scripts/generate-data.mjs",
"build:types": "node scripts/generate-types.mjs > index.d.ts"
"build:types": "node scripts/generate-types.mjs"
},
"files": [
"index.js",
Expand Down
12 changes: 6 additions & 6 deletions scripts/generate-types.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import fs from 'node:fs/promises';

const DATA_FILE = new URL('../globals.json', import.meta.url);

const globals = JSON.parse(await fs.readFile(DATA_FILE));
import fs from 'node:fs';
import globals from '../index.js';

const getGroupTypeName = group => `Globals${group[0].toUpperCase() + group.slice(1).replaceAll('-', '')}`;

Expand Down Expand Up @@ -33,4 +30,7 @@ for (const [group, groupType] of Object.entries(groups)) {

output.push('}\n', 'declare const globals: Globals;\n', 'export = globals;');

console.log(output.join('\n'));
fs.writeFileSync(
new URL('../index.d.ts', import.meta.url),
output.join('\n'),
);

0 comments on commit 8314faf

Please sign in to comment.