Skip to content

Commit 2628a0b

Browse files
feat(internal): make git install file structure match npm (#1204)
1 parent 3f8634e commit 2628a0b

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "./scripts/build",
1919
"prepublishOnly": "echo 'to publish, run yarn build && (cd dist; yarn publish)' && exit 1",
2020
"format": "prettier --write --cache --cache-strategy metadata . !dist",
21-
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build; fi",
21+
"prepare": "if ./scripts/utils/check-is-in-git-install.sh; then ./scripts/build && ./scripts/utils/git-swap.sh; fi",
2222
"tsn": "ts-node -r tsconfig-paths/register",
2323
"lint": "./scripts/lint",
2424
"fix": "./scripts/format"

Diff for: scripts/utils/check-is-in-git-install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Check if you happen to call prepare for a repository that's already in node_modules.
33
[ "$(basename "$(dirname "$PWD")")" = 'node_modules' ] ||
44
# The name of the containing directory that 'npm` uses, which looks like

Diff for: scripts/utils/git-swap.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -exuo pipefail
3+
# the package is published to NPM from ./dist
4+
# we want the final file structure for git installs to match the npm installs, so we
5+
6+
# delete everything except ./dist and ./node_modules
7+
find . -maxdepth 1 -mindepth 1 ! -name 'dist' ! -name 'node_modules' -exec rm -rf '{}' +
8+
9+
# move everything from ./dist to .
10+
mv dist/* .
11+
12+
# delete the now-empty ./dist
13+
rmdir dist

0 commit comments

Comments
 (0)