Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(run-pipeline-node): update args with mounted path on Windows #1148

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/typescript/itk-wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itk-wasm",
"version": "1.0.0-b.175",
"version": "1.0.0-b.176",
"packageManager": "[email protected]",
"description": "High-performance spatial analysis in a web browser, Node.js, and reproducible execution across programming languages and hardware architectures.",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path'

import loadEmscriptenModuleNode from './internal/load-emscripten-module-node.js'
import runPipelineEmscripten from './internal/run-pipeline-emscripten.js'

Expand All @@ -6,6 +8,37 @@ import PipelineOutput from './pipeline-output.js'
import PipelineInput from './pipeline-input.js'
import RunPipelineResult from './run-pipeline-result.js'

function windowsToEmscriptenPath (filePath: string): string {
// Following mount logic in itkJSPost.js
const fileBasename = path.basename(filePath)
const containingDir = path.dirname(filePath)
let mountedPath = '/'
const splitPath = containingDir.split(path.sep)
for (let ii = 1; ii < splitPath.length; ii++) {
mountedPath += splitPath[ii]
mountedPath += '/'
}
mountedPath += fileBasename
return mountedPath
}

function replaceArgumentsWithEmscriptenPaths (
args: string[],
mountDirs: Set<string>
): string[] {
if (typeof process === 'undefined' || process.platform !== 'win32') {
return args
}
return args.map((arg) => {
for (const mountDir of mountDirs) {
if (arg.startsWith(mountDir)) {
return windowsToEmscriptenPath(arg)
}
}
return arg
})
}

async function runPipelineNode (
pipelinePath: string,
args: string[],
Expand All @@ -22,6 +55,9 @@ async function runPipelineNode (
mountedDirs.add(Module.mountDir(dir))
})
}
if (typeof mountDirs !== 'undefined') {
args = replaceArgumentsWithEmscriptenPaths(args, mountDirs)
}
const result = runPipelineEmscripten(Module, args, outputs, inputs)
if (typeof mountDirs !== 'undefined') {
mountedDirs.forEach((dir) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/typescript/itk-wasm/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const version = '1.0.0-b.175'
const version = "1.0.0-b.176";

export default version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.1"

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.1"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.1"
2 changes: 1 addition & 1 deletion packages/image-io/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@itk-wasm/image-io",
"version": "1.2.0",
"version": "1.2.1",
"packageManager": "[email protected]",
"description": "Input and output for scientific and medical image file formats.",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.1"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.1"
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.2.0"
__version__ = "1.2.1"
2 changes: 1 addition & 1 deletion packages/mesh-io/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@itk-wasm/mesh-io",
"version": "1.2.0",
"version": "1.2.1",
"packageManager": "[email protected]",
"description": "Input and output for scientific and medical image file formats.",
"type": "module",
Expand Down
Loading