-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from script3/audit-update
feat: update gov interface and update to p21
- Loading branch information
Showing
5 changed files
with
108 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,37 +1,61 @@ | ||
import { spawnSync } from "node:child_process" | ||
import fs from "node:fs" | ||
import path from "node:path" | ||
import { spawnSync } from "node:child_process"; | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
|
||
const buildDir = "./dist" | ||
const buildDir = "./dist"; | ||
|
||
const { error, stderr } = spawnSync("tsc", ["-b", "./scripts/tsconfig.cjs.json", "./scripts/tsconfig.esm.json", "./scripts/tsconfig.types.json"], { stdio: "inherit" }) | ||
const { error, stderr } = spawnSync( | ||
"tsc", | ||
[ | ||
"-b", | ||
"./scripts/tsconfig.cjs.json", | ||
"./scripts/tsconfig.esm.json", | ||
"./scripts/tsconfig.types.json", | ||
], | ||
{ stdio: "inherit" } | ||
); | ||
|
||
if (error) { | ||
console.error(stderr) | ||
console.error(error) | ||
throw error | ||
console.error(stderr); | ||
console.error(error); | ||
throw error; | ||
} | ||
|
||
function createEsmModulePackageJson() { | ||
fs.readdir(buildDir, function (err, dirs) { | ||
if (err) { | ||
throw err | ||
throw err; | ||
} | ||
dirs.forEach(function (dir) { | ||
if (dir === "esm") { | ||
// 1. add package.json file with "type": "module" | ||
var packageJsonFile = path.join(buildDir, dir, "/package.json") | ||
if (!fs.existsSync(packageJsonFile)) { | ||
var esmPackageJson = path.join(buildDir, dir, "/package.json"); | ||
if (!fs.existsSync(esmPackageJson)) { | ||
fs.writeFileSync( | ||
packageJsonFile, | ||
esmPackageJson, | ||
'{"type": "module"}', | ||
'utf8', | ||
err => { if (err) throw err } | ||
) | ||
"utf8", | ||
(err) => { | ||
if (err) throw err; | ||
} | ||
); | ||
} | ||
} else if (dir === "cjs") { | ||
// 2. add package.json file with "type": "commonjs" | ||
var cjsPackageJson = path.join(buildDir, dir, "/package.json"); | ||
if (!fs.existsSync(cjsPackageJson)) { | ||
fs.writeFileSync( | ||
cjsPackageJson, | ||
'{"type": "commonjs"}', | ||
"utf8", | ||
(err) => { | ||
if (err) throw err; | ||
} | ||
); | ||
} | ||
} | ||
}) | ||
}) | ||
}); | ||
}); | ||
} | ||
|
||
createEsmModulePackageJson() | ||
createEsmModulePackageJson(); |
Oops, something went wrong.