Skip to content

Commit 21366ee

Browse files
authored
Wrote a shell script to simplify the build and test scripts (#44)
* bugfix: Removed dist folder before compilation * refactor: Wrote a shell script to simplify the build and test scripts * bugfix: Made script POSIX sh compliant --------- Co-authored-by: ijlee2 <[email protected]>
1 parent b3fa42f commit 21366ee

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
/.pnpm-debug.log
1818
/.prettierignore
1919
/.prettierrc.cjs
20+
/build.sh
2021
/codemod-test-fixture.sh
2122
/codemod-test-fixtures.sh
2223
/create-test-fixture.sh

build.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env sh
2+
3+
ENVIRONMENT=$1
4+
5+
if [ $ENVIRONMENT = "--production" ]
6+
then
7+
# Clean slate
8+
rm -rf "dist"
9+
10+
# Compile TypeScript
11+
tsc --project "tsconfig.build.json"
12+
13+
# Configure files
14+
chmod +x "dist/bin/ember-codemod-v1-to-v2.js"
15+
cp -r "src/blueprints" "dist/src/blueprints"
16+
17+
echo "SUCCESS: Built dist.\n"
18+
19+
elif [ $ENVIRONMENT = "--test" ]
20+
then
21+
# Clean slate
22+
rm -rf "dist-for-testing"
23+
24+
# Compile TypeScript
25+
tsc --project "tsconfig.json"
26+
27+
# Configure files
28+
cp -r "src/blueprints" "dist-for-testing/src/blueprints"
29+
30+
echo "SUCCESS: Built dist-for-testing.\n"
31+
32+
fi

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@
2727
"dist"
2828
],
2929
"scripts": {
30-
"build": "tsc --project tsconfig.build.json && chmod +x dist/bin/ember-codemod-v1-to-v2.js && cp -r src/blueprints dist/src/blueprints",
30+
"build": "./build.sh --production",
3131
"changelog": "lerna-changelog",
3232
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
3333
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
3434
"lint:js": "eslint . --cache",
3535
"lint:js:fix": "eslint . --fix",
3636
"lint:types": "tsc --noEmit",
3737
"prepare": "pnpm build",
38-
"test": "tsc --build && cp -r src/blueprints dist-for-testing/src/blueprints && mt dist-for-testing --quiet"
38+
"test": "./build.sh --test && mt dist-for-testing --quiet"
3939
},
4040
"dependencies": {
4141
"@codemod-utils/blueprints": "^0.2.0",

0 commit comments

Comments
 (0)