Node
node-gyp
for compiling native addon modules for Node.js
https://zhuanlan.zhihu.com/p/164543031
spawn inherit
在使用 spawn 执行 shell 时,如需直接获取和在 bash/zsh 中执行相同的效果,可以直接使用配置 stdio: ‘inherit’
const installCmd = spawn('yarn', ['install', '--force'], {
cwd,
stdio: 'inherit',
});
设置了 inherit 的 spawn,是不可进行 stdout 和 stderr 监听的,所以这是两种不同的用法
// installCmd.stdout.on('data', function (data) {
// console.log(`${data.toString().trim()}`);
// });
// installCmd.stdout.on('end', function () {
// });
// installCmd.stderr.on('data', function (data) {
// console.log(`install error: ${data}`);
// });
Shell
查看可用 shell 列表
cat /etc/shells
❯ cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
查看当前使用 shell
https://www.cnblogs.com/softwaretesting/archive/2012/02/14/2350688.html
ps | grep $$ | awk ‘{print $4}’
❯ ps | grep $$ | awk '{print $4}'
/bin/zsh
grep