1 | #!/bin/bash
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | if ! hash npm 2>/dev/null; then
|
7 | echo 'No NPM installed!'
|
8 | exit 1
|
9 | fi
|
10 |
|
11 |
|
12 | if npm -v 2>/dev/null | grep -q "^2."; then
|
13 | FILEPATH="node_modules/webpack/node_modules/watchpack/lib/DirectoryWatcher.js"
|
14 | else
|
15 | FILEPATH="node_modules/watchpack/lib/DirectoryWatcher.js"
|
16 | fi
|
17 |
|
18 | INSERTION_POINT_BEFORE="followSymlinks: false,"
|
19 | MISSING_OPTION="ignored: /node_modules/,"
|
20 |
|
21 | if ! cat ${FILEPATH} 2>/dev/null | grep -q "${MISSING_OPTION}"; then
|
22 | echo 'Fixing webpack watch (polling) slowness with a manual hack. See https://github.com/webpack/watchpack/pull/23 for more info.'
|
23 | sed -i -e 's|'"${INSERTION_POINT_BEFORE}"'|'"${INSERTION_POINT_BEFORE} ${MISSING_OPTION}"'|' "${FILEPATH}"
|
24 | fi
|