Skip to content

Commit

Permalink
fix: keep .d.ts and .js untouched if native doesn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo committed Dec 18, 2021
1 parent 3f2e44d commit 09c7df3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cli/src/build.ts
Expand Up @@ -354,6 +354,11 @@ async function processIntermediateTypeFile(
.split('\n')
.map((line) => line.trim())
.filter(Boolean)

if (!lines.length) {
return idents
}

const dtsHeader = `/* eslint-disable */
export class ExternalObject<T> {
Expand Down Expand Up @@ -466,7 +471,7 @@ async function writeJsBinding(
distFileName: string | null,
idents: string[],
) {
if (distFileName) {
if (distFileName && idents.length) {
const template = createJsBinding(localName, packageName)
const declareCodes = `const { ${idents.join(', ')} } = nativeBinding\n`
const exportsCode = idents.reduce(
Expand Down
1 change: 0 additions & 1 deletion crates/build/src/lib.rs
Expand Up @@ -2,7 +2,6 @@ mod macos;
mod windows;

pub fn setup() {
println!("cargo:rerun-if-env-changed=TYPE_DEF_TMP_PATH");
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE");
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
Ok("macos") => macos::setup(),
Expand Down

0 comments on commit 09c7df3

Please sign in to comment.