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

[FEATURE] allow to know user cancel sub process #1

Closed
bluelovers opened this issue Apr 9, 2020 · 1 comment
Closed

[FEATURE] allow to know user cancel sub process #1

bluelovers opened this issue Apr 9, 2020 · 1 comment

Comments

@bluelovers
Copy link

What / Why

n/a

import runScript from '@npmcli/run-script';
(async () => {
	let path = 'xxxx\\test\\res\\pkg-a';
	await runScript({
		event: 'pretest',
		path,
		stdioString: true,
		stdio: 'inherit',
	})
		.then((ret) =>
		{
			console.dir(ret)
		})
		.catch((e) =>
		{
			console.trace(e)
		})
	;
	await runScript({
		event: 'test',
		path,
		stdioString: true,
		stdio: 'inherit',
	})
		.then((ret) =>
		{
			console.dir(ret)
		})
		.catch((e) =>
		{
			console.trace(e)
		})
	;
})();
{
  "name": "pkg-a",
  "scripts": {
    "pretest": "echo pretest && npm init",
    "test": "echo test",
  }
}

When

  • n/a

Where

  • n/a

How

when npm init is ask input
send a ctrl + c ending it

Current Behavior

  • n/a
> pkg-a@1.0.0 pretest
> echo pretest && npm init
pretest
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (pkg-a) npm WARN init canceled
{
  cmd: 'C:\\WINDOWS\\system32\\cmd.exe',
  args: [ '/d', '/s', '/c', '"echo pretest && npm init"' ],
  code: 0,
  signal: null,
  stdout: '',
  stderr: '',
  event: 'pretest',
  script: 'echo pretest && npm init',
  pkgid: '[email protected]',
  path: 'test\\res\\pkg-a'
}
> pkg-a@1.0.0 test
> echo test
test
{
  cmd: 'C:\\WINDOWS\\system32\\cmd.exe',
  args: [ '/d', '/s', '/c', '"echo test"' ],
  code: 0,
  signal: null,
  stdout: '',
  stderr: '',
  event: 'test',
  script: 'echo test',
  pkgid: '[email protected]',
  path: 'test\\res\\pkg-a'
}

Expected Behavior

  • n/a

can know user is send ctrl + c from return message

Who

  • n/a

References

  • n/a
@isaacs
Copy link
Contributor

isaacs commented Nov 6, 2020

The plan (discussed in npm/cli#2124) is to proxy signals to and from child processes when run in foreground mode (ie, stdio: 'inherit').

@isaacs isaacs closed this as completed Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants