Skip to content

Mount option via command line is not working properly? #139

@DrKGD

Description

@DrKGD

Describe the bug
Can't really mount a directory via the --mount command line argument

five-server --port=60200 --mount=/img:./images
drwxr-xr-x - deatharte 26 Jun 22:18 images
/usr/lib/node_modules/five-server/lib/bin.js:142
            opts.mount.push([match[1], match[2]]);
                       ^
TypeError: Cannot read properties of undefined (reading 'push')
    at Object.<anonymous> (/usr/lib/node_modules/five-server/lib/bin.js:142:24)
    at Module._compile (node:internal/modules/cjs/loader:1460:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
    at Module.load (node:internal/modules/cjs/loader:1275:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12)
    at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
    at node:internal/main/run_main_module:30:49

Node.js v22.3.0

I suspect opts.mount is undefined?
opts.proxy may also be affected by same the issue.

five-server/src/bin.ts

Lines 111 to 120 in 594fb7f

} else if (arg.indexOf('--mount=') > -1) {
// e.g. "--mount=/components:./node_modules" will be ['/components', '<process.cwd()>/node_modules']
// split only on the first ":", as the path may contain ":" as well (e.g. C:\file.txt)
const match = arg.substring(8).match(/([^:]+):(.+)$/)
if (!match) message.error('Option --mount is wrong', null, false)
else {
match[2] = path.resolve(process.cwd(), match[2])
opts.mount.push([match[1], match[2]])
process.argv.splice(i, 1)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions