Skip to content

Legacy cml-command syntax broken on Windows #736

Closed

Description

@0x2b3bfa0
const [, base, command] = basename(file).match(/^(\w+)-(.+)$/);
                          ^

TypeError: basename is not iterable (cannot read property Symbol(Symbol.iterator))
    at Object.<anonymous> (D:\a\cml\cml\bin\legacy.js:12:27)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

NPM uses cmd-shim on Windows instead of creating symbolic links. This shim consists of a hardcoded script that calls the executables specified on package.json:bin with the node interpreter, and, because of the indirect call, $0 gets lost in the process.

cml/bin/legacy.js

Lines 11 to 12 in 7d664ae

const [, file, ...parameters] = process.argv;
const [, base, command] = basename(file).match(/^(\w+)-(.+)$/);

Because of this, basename(file) equals legacy.js instead of cml-command as expected. Therefore, /^(\w+)-(.+)$/ doesn't match anything (obviously) and we don't have any means to determine which legacy command was called.

Activity

  1. 0x2b3bfa0 commented on Sep 22, 2021

    @0x2b3bfa0
    MemberAuthor

    This only affects legacy commands on Windows, and doesn't have any easy realistic solution. Should we just ignore it?

  2. added 2 commits that reference this issue on Sep 22, 2021
    91a49d4
    0584a7a
  3. 0x2b3bfa0 commented on Sep 22, 2021

    @0x2b3bfa0
    MemberAuthor

    🔔 @iterative/cml, voting to close without changes through #737

  4. self-assigned this
    on Sep 22, 2021
  5. added
    bug
    testing
    on Sep 22, 2021
  6. added a commit that references this issue on Sep 23, 2021
    14ef16a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugtesting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions