-
Notifications
You must be signed in to change notification settings - Fork 719
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing typescript esm types (#1623)
* chore: add writeEsmPackageJson script * chore: update builds to emit type declaration files * docs: update changelog
- Loading branch information
1 parent
5b7c8c8
commit 00cb0ba
Showing
5 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env node | ||
|
||
import fs from 'node:fs/promises'; | ||
import { argv } from 'node:process'; | ||
import path from 'node:path'; | ||
import { writeFile } from 'node:fs/promises'; | ||
|
||
/** | ||
* @param {string} path | ||
* @returns {Promise<boolean>} | ||
*/ | ||
async function pathExists(path) { | ||
try { | ||
await fs.access(path); | ||
return true; | ||
} catch (_err) { | ||
return false; | ||
} | ||
} | ||
|
||
const directory = argv[2]; | ||
|
||
if (directory === undefined) { | ||
throw new Error('Expected a path'); | ||
} | ||
|
||
const directoryExists = await pathExists(directory); | ||
|
||
if (!directoryExists) { | ||
throw new Error(`Path ${directory} not found`); | ||
} | ||
|
||
const filePath = path.join(directory, 'package.json'); | ||
|
||
const packageJsonFileContent = JSON.stringify( | ||
{ | ||
type: 'module', | ||
}, | ||
undefined, | ||
2, | ||
); | ||
|
||
await writeFile(filePath, packageJsonFileContent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters