From d78b85dc328f80e9585ad62cbd7a6bc422693b6a Mon Sep 17 00:00:00 2001 From: Bartolomeu Date: Fri, 18 Jun 2021 22:34:05 +0100 Subject: [PATCH] bundle-declaration-references script improvements --- packages/not-me/package.json | 2 +- .../scripts/bundle-declaration-references.js | 15 ++++++++------- packages/not-me/tsconfig.watch.json | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/not-me/package.json b/packages/not-me/package.json index 53d329b..71e24e4 100644 --- a/packages/not-me/package.json +++ b/packages/not-me/package.json @@ -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" ], diff --git a/packages/not-me/scripts/bundle-declaration-references.js b/packages/not-me/scripts/bundle-declaration-references.js index d9e51bd..31727b8 100644 --- a/packages/not-me/scripts/bundle-declaration-references.js +++ b/packages/not-me/scripts/bundle-declaration-references.js @@ -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 + `/// ` + "\n"; }, ""); -writeFile("lib/index.d.ts", file).catch((err) => { - console.error(err); - process.exit(1); -}); +fs.writeFileSync(typesFile, declarationReferences); diff --git a/packages/not-me/tsconfig.watch.json b/packages/not-me/tsconfig.watch.json index 1f06691..9ecf373 100644 --- a/packages/not-me/tsconfig.watch.json +++ b/packages/not-me/tsconfig.watch.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", "exclude": ["**/*.*spec.ts", "**/spec/**/*.ts"] -} \ No newline at end of file +}