From a2cedcbb9d1a4daa383ee93f14551f024ccf83e8 Mon Sep 17 00:00:00 2001 From: mkslanc Date: Tue, 17 Dec 2024 15:29:48 +0400 Subject: [PATCH] separate clean declaration files function --- package.json | 4 ++-- tool/ace_declaration_generator.js | 13 +------------ tool/fs_utilities.js | 14 +++++++++++++- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 6e52d57085..7e85c27a11 100644 --- a/package.json +++ b/package.json @@ -39,13 +39,13 @@ "interfaces.d.ts" ], "scripts": { - "clean": "rimraf src/**/*.d.ts", + "clean:dts": "node -e \"require('./tool/fs_utilities').cleanDeclarationFiles()\"", "start": "node static.js", "test": "node src/test/all.js", "cover": "istanbul cover src/test/all.js", "lint": "eslint \"src/**/*.js\" \"*.js\"", "fix": "npm run lint -- --fix", - "typecheck": "tsc -p tsconfig.json", + "typecheck": "npm run clean:dts && tsc -p tsconfig.json", "update-types": "node ./tool/ace_declaration_generator.js", "changelog": "standard-version", "prepack": "node tool/esm_resolver_generator.js && node tool/ace_declaration_generator.js && node Makefile.dryice.js css --target build-styles && rm -rf styles && mv build-styles/css styles" diff --git a/tool/ace_declaration_generator.js b/tool/ace_declaration_generator.js index c7f83ab1fa..3c286c8c8a 100644 --- a/tool/ace_declaration_generator.js +++ b/tool/ace_declaration_generator.js @@ -1,7 +1,7 @@ const ts = require('typescript'); const fs = require("fs"); const path = require("path"); -var {getAllFiles} = require("./fs_utilities"); +var {getAllFiles, cleanDeclarationFiles} = require("./fs_utilities"); const AUTO_GENERATED_HEADER = "/* This file is generated using `npm run update-types` */\n\n"; @@ -733,17 +733,6 @@ function updateDeclarationModuleNames(content) { return output; } -function cleanDeclarationFiles() { - const baseDir = path.resolve(__dirname, '../src'); - const files = getAllFiles(baseDir); - - files.forEach(file => { - if (file.endsWith('.d.ts')) { - fs.unlinkSync(file); - } - }); -} - function bundleDtsFiles(buildPath) { const aceNamespacePath = __dirname + "/../ace-internal.d.ts"; if (!buildPath) { diff --git a/tool/fs_utilities.js b/tool/fs_utilities.js index 819a38013f..7401d188ae 100644 --- a/tool/fs_utilities.js +++ b/tool/fs_utilities.js @@ -20,4 +20,16 @@ function getAllFiles(dirPath) { return files; } -exports.getAllFiles = getAllFiles; \ No newline at end of file +function cleanDeclarationFiles() { + const baseDir = path.resolve(__dirname, '../src'); + const files = getAllFiles(baseDir); + + files.forEach(file => { + if (file.endsWith('.d.ts')) { + fs.unlinkSync(file); + } + }); +} + +exports.getAllFiles = getAllFiles; +exports.cleanDeclarationFiles = cleanDeclarationFiles; \ No newline at end of file