question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Command Mode not working on Windows

See original GitHub issue

Bug

  • version: 1.10.8
  • platform: windows

Description

The command mode does not work correctly on windows. The problem seems to be in the parsing of the CLI arguments. On Windows the arguments get split at every space and ignores any ' that should group arguments to a single command.

Example

command: npx start-test start:storybook 4001 'jest --config tests/screenshot/jest.config.js --ci'

actual behavior

compare the second line between Windows and Ubuntu

Windows Debug Output

> npx start-test start:storybook 4001 'jest --config tests/screenshot/jest.config.js --ci'
start-server-and-test parsing CLI arguments: [ 'start:storybook', '4001', "'jest", '--config', 'tests/screenshot/jest.config.js', "--ci'" ]

 throw err;
      ^

Error: expected <NPM script name that starts server> <url or port> <NPM script name that runs tests>
example: start-test start 8080 test
see https://github.com/bahmutov/start-server-and-test#use

    at lazyAssLogic (workdir\node_modules\lazy-ass\index.js:110:14)
    at lazyAss (workdir\node_modules\lazy-ass\index.js:115:28)
    at Object.getArguments (workdir\node_modules\start-server-and-test\src\utils.js:35:5)
    at Object.<anonymous> (workdir\node_modules\start-server-and-test\src\bin\start.js:10:22)
    at Module._compile (internal/modules/cjs/loader.js:1157:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47

Ubuntu Debug Output

> npx start-test start:storybook 4001 'jest --config tests/screenshot/jest.config.js --ci'
start-server-and-test parsing CLI arguments: [ 'start:storybook', '4001', 'jest --config tests/screenshot/jest.config.js --ci' ]
  start-server-and-test parsed args: { start: 'npm run start:storybook', url: [ 'http://localhost:4001' ], test: 'jest --config tests/screenshot/jest.config.js --ci' }

expected behaviour

  • execute jest with config in ci mode instead of throwing an error
  • parse commands like on Ubuntu and in the README

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Mar 7, 2020

If you open a pull request with tests I will gladly see to it

Sent from my iPhone

On Mar 7, 2020, at 13:54, Adrian Jost notifications@github.com wrote:

As I investigated further, I discovered that the working windows command does not work anymore on Ubuntu.

Maybe you could implement a fix that concats arguments if they begin with ’ or " and merge them until an argument ends with ’ or ". This would make it possible to run on both systems with the same command.

Implementation Idea:

let args = process.argv.slice(2)

let concatMode = false; const combinedArgs = [] for (let i = 0; i < args.length; i++){ let arg = args[i]; if(args[i].startsWith(') || args[i].startsWith(")){ concatMode = true; arg = arg.slice(1) } if(arg.endsWith(') || arg.endsWith(")){ arg = arg.slice(0,-1) }

if(concatMode && combinedArgs.length){ combinedArgs[combinedArgs.length - 1] += arg }else{ combinedArgs.push(arg) }

if(args[i].endsWith(') || args[i].endsWith(")){ concatMode = false; } }

// use combinedArgs instead of args — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

0reactions
github-actions[bot]commented, May 24, 2021

🎉 This issue has been resolved in version 1.12.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Prompt not working or opening in Windows 11/10
Command Prompt not working or opening in Windows 11/10 · Launch Command Prompt from File Explorer. · Try opening Command Prompt from Task...
Read more >
Fixed: Command Prompt Not Working in Windows 11/10
Command Prompt is not working in Windows 11/10 ; Fix 1. Use CMD Alternative, Run CMD alternative software > Right-click target partition to...
Read more >
How to Fix Command Prompt Not Working in Windows 10 Error
How to Fix Command Prompt Not Working in Windows 10 Error · 1. Check Antivirus · 2. Command Prompt Shortcut · 3. Create...
Read more >
8 Ways to Fix the Windows Command Prompt When It's ...
8 Ways to Fix the Windows Command Prompt When It's Unresponsive · 1. Close Active Tasks or Restart Your Device · 2. Access...
Read more >
Command Prompt Not Working Or Opening on Windows 11 or ...
Fix: Command Prompt Not Working Or Opening on Windows 11 or 10 · Fix 1 – Try ending task of cmd in task...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found