Merge pull request #941 from napi-rs/fix/build-env
fix(build): keep `.d.ts` and `.js` untouched if native doesn't change
This commit is contained in:
commit
45a74856d6
2 changed files with 6 additions and 2 deletions
|
@ -354,6 +354,11 @@ async function processIntermediateTypeFile(
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((line) => line.trim())
|
.map((line) => line.trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
||||||
|
if (!lines.length) {
|
||||||
|
return idents
|
||||||
|
}
|
||||||
|
|
||||||
const dtsHeader = `/* eslint-disable */
|
const dtsHeader = `/* eslint-disable */
|
||||||
|
|
||||||
export class ExternalObject<T> {
|
export class ExternalObject<T> {
|
||||||
|
@ -466,7 +471,7 @@ async function writeJsBinding(
|
||||||
distFileName: string | null,
|
distFileName: string | null,
|
||||||
idents: string[],
|
idents: string[],
|
||||||
) {
|
) {
|
||||||
if (distFileName) {
|
if (distFileName && idents.length) {
|
||||||
const template = createJsBinding(localName, packageName)
|
const template = createJsBinding(localName, packageName)
|
||||||
const declareCodes = `const { ${idents.join(', ')} } = nativeBinding\n`
|
const declareCodes = `const { ${idents.join(', ')} } = nativeBinding\n`
|
||||||
const exportsCode = idents.reduce(
|
const exportsCode = idents.reduce(
|
||||||
|
|
|
@ -2,7 +2,6 @@ mod macos;
|
||||||
mod windows;
|
mod windows;
|
||||||
|
|
||||||
pub fn setup() {
|
pub fn setup() {
|
||||||
println!("cargo:rerun-if-env-changed=TYPE_DEF_TMP_PATH");
|
|
||||||
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE");
|
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE");
|
||||||
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
|
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
|
||||||
Ok("macos") => macos::setup(),
|
Ok("macos") => macos::setup(),
|
||||||
|
|
Loading…
Reference in a new issue