From 699814092c0a84d5132357b167bd9e6fca76b57f Mon Sep 17 00:00:00 2001 From: Max Isom Date: Mon, 4 Jan 2021 15:07:13 -0600 Subject: [PATCH] Fix .env with pkg --- .github/workflows/release.yml | 1 + package.json | 3 ++- src/hooks/init.ts | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efb1ee0..198af1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/package.json b/package.json index c8f5c3a..cd50a83 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ ] }, "pkg": { - "scripts": "./lib/**/*.js" + "scripts": "./lib/**/*.js", + "assets": ".env" }, "oclif": { "commands": "./lib/commands", diff --git a/src/hooks/init.ts b/src/hooks/init.ts index a2a0807..c28fda6 100644 --- a/src/hooks/init.ts +++ b/src/hooks/init.ts @@ -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;