小编k23*_*3j4的帖子

带有字符串而不是数组的nodejs spawn命令?

我正在研究spawnnodejs。以前我使用过,exec但 exec 在 stdout(或 stderr)流中没有兼容性。现在,我对 spawn 有障碍。似乎 exec 接受了带引号的字符串命令,而 spawn 不接受那个命令,只是数组格式。

所以下面的 exec 脚本工作正常,但另一个使用 spawn 的脚本会出错,因为字符串格式的命令不是数组。

const exec = require('child_process').exec;

exec(` echo foo bar `, (error, stdout, stderr) => {
  if ( error ){ console.log(error) }
  if ( stdout ){ console.log(stdout) }
  if ( stderr ){ console.log(stderr) }
});
Run Code Online (Sandbox Code Playgroud)
const { spawn } = require('child_process');

command = spawn('echo foo bar');

command.stdout.on('data', function (data) {
  console.log(data.toString());
});

command.stderr.on('data', function (data) {
  console.log( data.toString());
});

command.on('exit', function (code) …
Run Code Online (Sandbox Code Playgroud)

node.js

6
推荐指数
2
解决办法
1825
查看次数

您如何亚行到bluestacks 4?

我想使用adb连接到bluestacks 4上的android模拟器。但我有一个错误adb.exe -s emulator-5554 shell

检查设备。

$ adb.exe devices
List of devices attached
BH901...      device
CB512...      unauthorized





emulator-5554   device
Run Code Online (Sandbox Code Playgroud)

一旦我关闭bluestacks窗口,该emulator-5554命令将从上面的结果中隐藏。因此,我认为这emulator-5554意味着bluestacks。

然后如下所示使用adb。

$ adb.exe -s emulator-5554 shell
error: closed
Run Code Online (Sandbox Code Playgroud)

但是如您所知,发生了错误。

android adb bluestacks

5
推荐指数
2
解决办法
6665
查看次数

使用 ag 进行多行正则表达式搜索

我想通过正则表达式和 ag(the_silver_searcher) 在文件中的特定多行范围内“AND”搜索文本。但正则表达式模式不起作用。

遵循正则表达式模式效果很好。

ag --multiline -G "^.*\.(md|txt)$" -C 1 -S "foo(\n|.)*baz" ./dev_note.md

(输出)

40-
41:foo
42:bar
43:baz
44-
Run Code Online (Sandbox Code Playgroud)

但遵循正则表达式模式将不会输出任何内容。(不匹配)

ag --multiline -G "^.*\.(md|txt)$" -C 1 -S "(?=(.|\n)*(foo))(?=(.|\n)*(baz))" ./dev_note.md

我也尝试过:ag --multiline -G "^.*\.(md|txt)$" -C 1 -S "(?=(.|\n)*(foo))(.|\n)*(?=(.|\n)*(baz))" ./dev_note.md

regex ag

5
推荐指数
0
解决办法
1833
查看次数

标签 统计

adb ×1

ag ×1

android ×1

bluestacks ×1

node.js ×1

regex ×1