Skip to content

Commit

Permalink
add bash script
Browse files Browse the repository at this point in the history
  • Loading branch information
pankaj443 committed Aug 14, 2023
1 parent bd7dd7e commit 1f71532
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Lint
on: push
jobs:
lint:
name: Build
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- run: ./scripts/build.sh
60 changes: 60 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
mkdir temp && cd temp

npm init -y

npm install --save-dev @percy/cli

npm install -g pkg

cd ..

yarn install

cp -R ./temp//node_modules/@percy/* packages/

sed -i '' '/"type": "module",/d' ./package.json

cd packages && sed -i '' '/"type": "module",/d' ./*/package.json && cd ..

echo "import { cli } from '@percy/cli';\n$(cat ./packages/cli/dist/percy.js)" > ./packages/cli/dist/percy.js

sed -i '' '/Imports and returns compatibile CLI commands from various sources/a \
function formatFilepath(filepath) {\
let path = url.pathToFileURL(filepath).href.replace("file:///","");\
if (!path.includes("C:")) {\
path = "/" + path;\
}\
return path;\
}
' ./packages/cli/dist/commands.js

sed -i '' 's/import(url.pathToFileURL(modulePath).href);/import(formatFilepath(modulePath));/g' ./packages/cli/dist/commands.js

echo "import { execSync } from 'child_process';\n$(cat ./packages/core/dist/install.js)" > ./packages/core/dist/install.js

sed -i '' '/extract the downloaded file/a \
var output = execSync(command, { encoding: "utf-8" }).trim();\
archive = output.concat("/", archive);\
outdir = output.concat("/", outdir);
' ./packages/core/dist/install.js

sed -i '' '/let archive/a \
var command = "pwd";\
if (archive.includes("C:")) {\
command = "cd";\
}\
outdir = outdir.replace("C:\\\\","");\
archive = archive.replace("C:\\\\","");
' ./packages/core/dist/install.js

sed -i '' '/let outdir/a \
if (outdir.charAt(0) == "/") {\
outdir = outdir.replace("/", "");\
}
' ./packages/core/dist/install.js

npm run build_cjs

cp -R ./build/* packages/

pkg ./packages/cli/bin/run.js -d

0 comments on commit 1f71532

Please sign in to comment.