Skip to content

Commit

Permalink
Fix .env with pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
codetheweb committed Jan 4, 2021
1 parent 04ade25 commit 6998140
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
- name: Install dependencies
run: yarn install

# Need to create a .env instead of just exposing process.env because pkg won't inline env vars
- name: Build .env
run: echo BASE_URL=${{ secrets.BASE_URL }} > .env

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
]
},
"pkg": {
"scripts": "./lib/**/*.js"
"scripts": "./lib/**/*.js",
"assets": ".env"
},
"oclif": {
"commands": "./lib/commands",
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/init.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {Hook} from '@oclif/config';
import * as path from 'path';

const hook: Hook<'init'> = async function (options) {
// Load environment variables
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('dotenv').config();
require('dotenv').config({path: path.join(__dirname, '../../.env')});
};

export default hook;

0 comments on commit 6998140

Please sign in to comment.