Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
chore: omit preamble from generated index.d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Oct 22, 2023
1 parent a1a12d9 commit 1a8d0a6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"devDependencies": {
"@carbon/icons": "11.28.0",
"@types/react": "^18.2.25",
"@types/react": "^18.2.31",
"bun-types": "latest",
"dprint": "^0.41.0"
}
Expand Down
16 changes: 4 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { BuildIcons } from "@carbon/icons";
import metadata from "@carbon/icons/metadata.json";
import fs from "fs";
import path from "path";
import packageJson from "../package.json";
import { ensureFolder, getVersion } from "./utils";
import fs from "node:fs";
import path from "node:path";
import { ensureFolder } from "./utils";

interface GenCarbonIconsReactTypesOptions {
/** @default Infinity */
Expand Down Expand Up @@ -60,14 +59,7 @@ export const genCarbonIconsReactTypes = (
});
});

const version = getVersion(packageJson.devDependencies["@carbon/icons"]);
const preamble = `// Type definitions for @carbon/icons-react ${version}
// Project: https://github.com/carbon-design-system/carbon/tree/master/packages/icons-react
// Definitions by: Eric Liu <https://github.com/metonym>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 4.0
/** ${data.length} icons total */
const preamble = `/** ${data.length} icons total */
export interface CarbonIconProps
extends Omit<
Expand Down
6 changes: 1 addition & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import fs from "fs";
import fs from "node:fs";

export const ensureFolder = (folder: string) => {
if (fs.existsSync(folder)) fs.rmSync(folder, { recursive: true });
fs.mkdirSync(folder, { recursive: true });
};

export const getVersion = (semver: string) => {
return semver.slice(0, -2).replace(/^(\^|~)/, "");
};

0 comments on commit 1a8d0a6

Please sign in to comment.