Skip to content

Commit

Permalink
bundle-declaration-references script improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartmr committed Jun 18, 2021
1 parent d8ab2a9 commit d78b85d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/not-me/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.2",
"description": "Easy and type-safe validation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"types": "lib/types.d.ts",
"files": [
"lib"
],
Expand Down
15 changes: 8 additions & 7 deletions packages/not-me/scripts/bundle-declaration-references.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
const glob = require("glob");
const { promisify } = require("util");
const fs = require("fs");
const writeFile = promisify(fs.writeFile);

const declarationFiles = glob.sync("lib/**/*.d.ts");

const file = declarationFiles.reduce((content, current) => {
const typesFile = "lib/types.d.ts";

const declarationReferences = declarationFiles.reduce((content, current) => {
if (current === typesFile) {
return content;
}

const relativePath = current.substring(4);

return content + `/// <reference path="./${relativePath}" />` + "\n";
}, "");

writeFile("lib/index.d.ts", file).catch((err) => {
console.error(err);
process.exit(1);
});
fs.writeFileSync(typesFile, declarationReferences);
2 changes: 1 addition & 1 deletion packages/not-me/tsconfig.watch.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["**/*.*spec.ts", "**/spec/**/*.ts"]
}
}

0 comments on commit d78b85d

Please sign in to comment.