forked from ComPlat/chemotion_ELN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_postinstall.sh
executable file
·38 lines (28 loc) · 1.69 KB
/
package_postinstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
## package.json postinstall script
set -euo pipefail
src1=$(node -e 'console.log(require.resolve("@citation-js/core/lib-mjs/util/fetchFile.js"))')
src2=$(node -e 'console.log(require.resolve("@citation-js/core/lib-mjs/index.js"))')
src3=$(node -e 'console.log(require.resolve("@citation-js/plugin-bibtex/lib-mjs/input/constants.js"))')
src4=$(node -e 'console.log(require.resolve("@citation-js/plugin-wikidata/lib-mjs/entity.js"))')
[[ -e "$src1" && -e "$src2" && -e "$src3" && -e "$src4" ]] || exit 1
YEL='\033[0;33m'
NOC='\033[0m'
yellow() {
printf "${YEL}${1:-}${NOC}\n"
}
yellow "rewrite import for citation.js in:"
yellow "$src1"
sed -i "s~import { version } from '../../package.json';~import pkg from '../../package.json';const version = pkg.version;~" $src1
yellow "$src2"
sed -i "s~import { version } from '../package.json';~import pkg from '../package.json';const version = pkg.version;~" $src2
yellow "$src3"
sed -i "s~export { diacritics, commands } from './unicode.json';~import unicode from './unicode.json';export const diacritics = unicode.diacritics;export const commands = unicode.commands;~" $src3
yellow "$src4"
sed -i "s~import { props, ignoredProps } from './props';~import wikiprops from './props';const { props, ignoredProps } = wikiprops ;~" $src4
yellow "Done fixing import."
# move svgedit to public folder
yellow "Adding symbolic link to svg editor in public folder"
node_modules_folder="$(node -e 'const p = require.resolve("@svgedit/svgcanvas"); console.log(p.slice(0, p.indexOf("@svgedit/svgcanvas")))')"
rm -f ./public/svgedit && ln -s "$node_modules_folder"/svgedit/dist/editor ./public/svgedit
yellow "Finished adding symbolic link to svg editor in public folder"