Skip to content

Commit

Permalink
chore(NODE-5128): add script to clean dts and dts.map files (#3606)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken authored Mar 21, 2023
1 parent cb1ea8a commit 054872d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 162 deletions.
27 changes: 27 additions & 0 deletions etc/clean_definition_files.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /usr/bin/env node
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');

function* walk(root) {
const directoryContents = fs.readdirSync(root);
for (const filepath of directoryContents) {
const fullPath = path.join(root, filepath);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
yield* walk(fullPath);
} else if (stat.isFile()) {
yield fullPath;
}
}
}

const libPath = path.resolve(__dirname, '..', 'lib');
if (fs.existsSync(libPath)) {
const definitionFiles = Array.from(walk(libPath)).filter(filePath => {
return filePath.endsWith('.d.ts') || filePath.endsWith('.d.ts.map');
});
for (const definitionFile of definitionFiles) {
fs.unlinkSync(definitionFile);
}
}
160 changes: 0 additions & 160 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"mongodb-legacy": "^5.0.0",
"nyc": "^15.1.0",
"prettier": "^2.8.4",
"rimraf": "^4.4.0",
"semver": "^7.3.8",
"sinon": "^15.0.2",
"sinon-chai": "^3.7.0",
Expand All @@ -109,7 +108,7 @@
"scripts": {
"build:evergreen": "node .evergreen/generate_evergreen_tasks.js",
"build:ts": "node ./node_modules/typescript/bin/tsc",
"build:dts": "npm run build:ts && api-extractor run && rimraf 'lib/**/*.d.ts*'",
"build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs",
"build:docs": "./etc/docs/build.ts",
"build:typedoc": "typedoc",
"check:bench": "node test/benchmarks/driverBench",
Expand Down

0 comments on commit 054872d

Please sign in to comment.