#!/bin/bash
install -d ${PREFIX}/bin
install -d ${PREFIX}/lib/node_modules/pyright
install -d ${PREFIX}/share/doc/pyright
install -d ${PREFIX}/share/licenses/pyright

npm install
cd packages/pyright
npm run build

cp -r dist ${PREFIX}/lib/node_modules/pyright/dist
install -Dm755 index.js ${PREFIX}/lib/node_modules/pyright/index.js
install -Dm755 langserver.index.js ${PREFIX}/lib/node_modules/pyright/langserver.index.js
ln -s ${PREFIX}/lib/node_modules/pyright/index.js ${PREFIX}/bin/pyright
ln -s ${PREFIX}/lib/node_modules/pyright/langserver.index.js ${PREFIX}/bin/pyright-langserver

cd ../../

install -Dm644 README.md ${PREFIX}/share/doc/pyright/README.md
install -Dm644 CONTRIBUTING.md ${PREFIX}/share/doc/pyright/CONTRIBUTING.md
cp -r docs ${PREFIX}/share/doc/pyright/docs
install -Dm644 LICENSE.txt ${PREFIX}/share/licenses/pyright/LICENSE.txt
