update script setup for different npm versions

This commit is contained in:
Jon Ruskin 2021-02-13 20:00:18 -07:00
Родитель 3b9e5118e1
Коммит 39f8e9ba98
4 изменённых файлов: 33 добавлений и 1 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -17,6 +17,7 @@ test/fixtures/bower/bower_components
test/fixtures/npm/node_modules
test/fixtures/npm/package-lock.json
test/fixtures/npm/package.json
test/fixtures/go/src/*
test/fixtures/go/pkg

Просмотреть файл

@ -10,8 +10,25 @@ fi
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
cd $BASE_PATH/test/fixtures/npm
FORCE=""
if [ "$1" == "-f" ]; then
find . -not -regex "\.*" -and -not -name "package\.json" -print0 | xargs -0 rm -rf
FORCE=1
fi
NPM_MAJOR_VERSION="$(npm -v | cut -d'.' -f1)"
if [ "$NPM_MAJOR_VERSION" -ge "7" ]; then
PACKAGE_JSON_SRC="package.json.npm7"
else
PACKAGE_JSON_SRC="package.json.npm6"
fi
if [ ! -f "package.json" ] || [ "$(cat package.json | md5sum )" != "$(cat "$PACKAGE_JSON_SRC" | md5sum)" ]; then
FORCE=1
cp -f "$PACKAGE_JSON_SRC" package.json
fi
if [ -n "$FORCE" ]; then
find . -not -regex "\.*" -and -not -name "package\.json*" -print0 | xargs -0 rm -rf
fi
npm install

Просмотреть файл

14
test/fixtures/npm/package.json.npm7 поставляемый Normal file
Просмотреть файл

@ -0,0 +1,14 @@
{
"name": "fixtures",
"version": "1.0.0",
"dependencies": {
"@github/query-selector": "1.0.3",
"autoprefixer": "5.2.0"
},
"devDependencies": {
"string.prototype.startswith": "0.2.0"
},
"description": "npm test fixture",
"repository": "https://github.com/github/licensed",
"license": "MIT"
}