如果您没有成功使用终端包,您可以尝试process-palette. 它允许您精确定义命令的所有细节,包括环境变量。我制作了一个 Atom 命令,NODE_ENV在执行终端命令之前设置为任意字符串。截图如下:


下面是process-palette.json定义我编写的命令的文件。您需要做的就是安装软件包,使用以下代码创建该文件,然后选择Packages -> Process Palette -> Edit Configuration.
{
"patterns": {
"P1": {
"expression": "(path):(line)"
},
"P2": {
"expression": "(path)\\s+(line)",
"path": "(?:\\/[\\w\\.\\-]+)+"
}
},
"commands": [
{
"namespace": "process-palette",
"action": "env",
"command": "echo %NODE_PATH%",
"arguments": [],
"cwd": null,
"inputDialogs": [],
"env": {
"NODE_PATH": "wargarble"
},
"keystroke": null,
"stream": true,
"outputTarget": "panel",
"outputBufferSize": 80000,
"maxCompleted": 3,
"autoShowOutput": true,
"autoHideOutput": false,
"scrollLockEnabled": false,
"singular": false,
"promptToSave": true,
"saveOption": "none",
"patterns": [
"default"
],
"successOutput": "{stdout}",
"errorOutput": "{stdout}\n{stderr}",
"fatalOutput": "Failed to execute : {fullCommand}\n{stdout}\n{stderr}",
"startMessage": null,
"successMessage": "Executed : {fullCommand}",
"errorMessage": "Executed : {fullCommand}\nReturned with code {exitStatus}\n{stderr}",
"fatalMessage": "Failed to execute : {fullCommand}\n{stdout}\n{stderr}",
"menus": [
"env"
],
"startScript": null,
"successScript": null,
"errorScript": null,
"scriptOnStart": false,
"scriptOnSuccess": false,
"scriptOnError": false,
"notifyOnStart": false,
"notifyOnSuccess": true,
"notifyOnError": true,
"input": null
}
]
}