Skip to content

Commit

Permalink
fix(bindgen): local package.json path in pipelines-base-url.ts
Browse files Browse the repository at this point in the history
Also add writeIfOverrideNotPresent support.
  • Loading branch information
thewtex committed Nov 12, 2023
1 parent b969873 commit dc69e2e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/bindgen/typescript/resources/pipeline-worker-url.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Generated file. To retain edits, remove this comment.

import { getPipelineWorkerUrl as itkWasmGetPipelineWorkerUrl } from 'itk-wasm'

let pipelineWorkerUrl: string | URL | null | undefined
Expand Down
4 changes: 3 additions & 1 deletion src/bindgen/typescript/resources/pipelines-base-url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Generated file. To retain edits, remove this comment.

import { getPipelinesBaseUrl as itkWasmGetPipelinesBaseUrl } from 'itk-wasm'
import packageJson from '../package.json'
import packageJson from './package.json'

let pipelinesBaseUrl: string | URL | undefined
let defaultPipelinesBaseUrl: string | URL = `https://cdn.jsdelivr.net/npm/<bindgenPackageName>@${packageJson.version}/dist/pipelines`
Expand Down
4 changes: 2 additions & 2 deletions src/bindgen/typescript/write-support-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function writeSupportFiles(outputDir, forNode, bindgenResource, packageName, pac
fs.copyFileSync(bindgenResource('pipelines-base-url.ts'), pipelinesBaseUrlPath)
let pipelinesBaseUrlPathContent = fs.readFileSync(bindgenResource('pipelines-base-url.ts'), { encoding: 'utf8', flag: 'r' })
pipelinesBaseUrlPathContent = pipelinesBaseUrlPathContent.replaceAll('<bindgenPackageName>', packageName)
fs.writeFileSync(pipelinesBaseUrlPath, pipelinesBaseUrlPathContent)
writeIfOverrideNotPresent(pipelinesBaseUrlPath, pipelinesBaseUrlPathContent)
}
const pipelineWorkerUrlPath = path.join(outputDir, 'src', 'pipeline-worker-url.ts')
if (!fs.existsSync(pipelineWorkerUrlPath)) {
let pipelineWorkerUrlPathContent = fs.readFileSync(bindgenResource('pipeline-worker-url.ts'), { encoding: 'utf8', flag: 'r' })
pipelineWorkerUrlPathContent = pipelineWorkerUrlPathContent.replaceAll('<bindgenPackageName>', packageName)
fs.writeFileSync(pipelineWorkerUrlPath, pipelineWorkerUrlPathContent)
writeIfOverrideNotPresent(pipelineWorkerUrlPath, pipelineWorkerUrlPathContent)
}

const indexWorkerEmbeddedPath = path.join(outputDir, 'src', 'index-worker-embedded.ts')
Expand Down

0 comments on commit dc69e2e

Please sign in to comment.