문제

I'm new to nodejs, and am not sure how I can enable harmony features in nodeunit?

I know I can enable them in node by using the --harmony flag, but nodeunit does not have this flag. I'm looking specifically to make let work.

도움이 되었습니까?

해결책

This might not work for all cases, but we can add the --harmony flag in the nodeunit startup script:

batch:

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" --harmony "%~dp0\..\nodeunit\bin\nodeunit" %*
) ELSE (
  node --harmony "%~dp0\..\nodeunit\bin\nodeunit" %*
)

sh:

#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node" --harmony "$basedir/../nodeunit/bin/nodeunit" "$@"
  ret=$?
else 
  node --harmony "$basedir/../nodeunit/bin/nodeunit" "$@"
  ret=$?
fi
exit $ret

다른 팁

On Linux, if you have nodeunit installed globally (npm install -g nodeunit), this works just fine:

node --harmony `which nodeunit` /path/to/tests

On a Mac with the default install locations, a quick one liner:

node --harmony /usr/local/bin/nodeunit /path/to/your/testFile.js 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top