Skip to content

Commit

Permalink
fix: Supporting post install script on Windows (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
theproducer committed Jul 25, 2023
1 parent d5aa135 commit 75b4ed0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apps/example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@capacitor/android": "^4.7.3",
"@capacitor/app": "4.0.1",
"@capacitor/background-runner": "^4.0.0-rc.1",
"@capacitor/background-runner": "^1.0.0-rc.1",
"@capacitor/core": "^4.7.3",
"@capacitor/haptics": "4.1.0",
"@capacitor/ios": "^4.7.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/capacitor-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"android/build.gradle",
"dist/",
"ios/Plugin/",
"scripts/install_libs.js",
"CapacitorBackgroundRunner.podspec"
],
"author": "Ionic Team",
Expand Down Expand Up @@ -43,7 +44,7 @@
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build",
"postinstall": "mkdir -p $INIT_CWD/android/app/libs/ && cp -f android/src/main/libs/android-js-engine-release.aar $INIT_CWD/android/app/libs/"
"postinstall": "node ./scripts/install_libs.js"
},
"devDependencies": {
"@capacitor/android": "^5.2.1",
Expand Down
30 changes: 30 additions & 0 deletions packages/capacitor-plugin/scripts/install_libs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const path = require('path');

let workingDir = process.env.INIT_CWD;
if (!workingDir) {
workingDir = '.';
}

if (!fs.existsSync(path.join(workingDir, 'android'))) {
console.warn(
'cannot install android-js-engine library: @capacitor/android not installed, or in wrong parent directory.',
);
return;
}

const releaseAARPath = path.join(
'android/src/main/libs/android-js-engine-release.aar',
);

const fullPath = path.join(workingDir, 'android/app/libs');
if (!fs.existsSync(fullPath)) {
fs.mkdirSync(fullPath);
}

fs.copyFileSync(
releaseAARPath,
path.join(fullPath, 'android-js-engine-release.aar'),
);

console.log(`copied android-js-engine-release.aar to ${fullPath}`);
13 changes: 2 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 75b4ed0

Please sign in to comment.