相关疑难解决方法(0)

如何在Makefile中设置子进程的环境变量

我想更改这个Makefile:

SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)

boot:
    @supervisor         \
      --harmony         \
      --watch etc,lib       \
      --extensions js,json      \
      --no-restart-on error     \
        lib

test:
    NODE_ENV=test mocha         \
      --harmony             \
      --reporter spec       \
        test

clean:
    @rm -rf node_modules

.PHONY: test clean
Run Code Online (Sandbox Code Playgroud)

至:

SHELL := /bin/bash
PATH  := node_modules/.bin:$(PATH)

boot:
    @supervisor         \
      --harmony         \
      --watch etc,lib       \
      --extensions js,json      \
      --no-restart-on error     \
        lib

test: NODE_ENV=test
test:
    mocha                   \
      --harmony             \
      --reporter spec       \
        test

clean:
    @rm -rf node_modules

.PHONY: test clean
Run Code Online (Sandbox Code Playgroud)

不幸的是,第二个不起作用(节点进程仍以默认值运行) …

shell makefile environment-variables target

109
推荐指数
3
解决办法
15万
查看次数

在Makefile中设置环境变量时的@前缀

这是我到目前为止所得到的:

SPECS = $(shell find spec -iname "*_spec.js")

spec:
    @NODE_ENV=test \
    @NODE_PATH=lib \
    ./node_modules/.bin/expresso \
    $(TESTFLAGS) \
    $(SPECS)

cov:
    @TESTFLAGS=--cov $(MAKE) spec

.PHONY: spec cov
Run Code Online (Sandbox Code Playgroud)

输出: /bin/sh: @NODE_PATH=lib: command not found

如果我设置一个变量只是它工作正常.我究竟做错了什么?

makefile environment-variables

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

environment-variables ×2

makefile ×2

shell ×1

target ×1