-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: npm and JSR package contents (#16)
Co-authored-by: Francesco Trotta <github@fasttime.org>
- Loading branch information
Showing
7 changed files
with
47 additions
and
27 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
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
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,35 @@ | ||
/** | ||
* @fileoverview Prepends a TypeScript reference comment to the beginning of a file. | ||
* This is necessary because JSR requires that all JavaScript files have a reference | ||
* to the TypeScript types file. We can't do this in Rollup because that happens | ||
* before tsc is run. This script is run after tsc is run. | ||
* | ||
* Usage: | ||
* node tools/prepend-type-ref.js filename.js | ||
* | ||
* @author Nicholas C. Zakas | ||
*/ | ||
/* global process */ | ||
//----------------------------------------------------------------------------- | ||
// Imports | ||
//----------------------------------------------------------------------------- | ||
|
||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
|
||
//----------------------------------------------------------------------------- | ||
// Main | ||
//----------------------------------------------------------------------------- | ||
|
||
// read file from the command line | ||
const filePath = process.argv[2]; | ||
const filename = path.basename(filePath, ".js"); | ||
|
||
// read the file | ||
const contents = fs.readFileSync(filePath, "utf8"); | ||
|
||
// prepend the reference comment | ||
const newContents = `/// <reference types="./${filename}.d.ts" />\n${contents}`; | ||
|
||
// write the file back out | ||
fs.writeFileSync(filePath, newContents, "utf8"); |