run-with-heroku-env 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.oxfmtrc.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "arrowParens": "avoid",
3
+ "singleQuote": true,
4
+ "jsxSingleQuote": true,
5
+ "trailingComma": "none",
6
+ "printWidth": 80,
7
+ "sortPackageJson": false,
8
+ "ignorePatterns": []
9
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "run-with-heroku-env",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "execute command with heroku env",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "prettier --check .",
8
- "prettier-write": "prettier --write ."
7
+ "test": "oxfmt --check .",
8
+ "format": "oxfmt --write ."
9
9
  },
10
10
  "bin": {
11
11
  "run-with-heroku-env": "run-with-heroku-env.js"
@@ -24,7 +24,10 @@
24
24
  "url": "https://github.com/shokai/run-with-heroku-env/issues"
25
25
  },
26
26
  "homepage": "https://github.com/shokai/run-with-heroku-env#readme",
27
+ "publishConfig": {
28
+ "registry": "https://registry.npmjs.org/"
29
+ },
27
30
  "devDependencies": {
28
- "prettier": "^3.6.2"
31
+ "oxfmt": "^0.42.0"
29
32
  }
30
33
  }
@@ -1,22 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const pkg = require('./package.json');
4
- const { execSync, spawn } = require('child_process');
4
+ const { execFileSync, spawn } = require('child_process');
5
5
  const parseArgv = require('./parse-argv');
6
6
 
7
7
  function getHerokuEnvs({ envs, herokuOptions } = {}) {
8
- const option = Object.keys(herokuOptions)
9
- .map(key => `--${key} ${herokuOptions[key]}`)
10
- .join(' ');
8
+ const args = ['config', '--json'];
9
+ for (const key of Object.keys(herokuOptions)) {
10
+ args.push(`--${key}`);
11
+ if (herokuOptions[key] !== true) {
12
+ args.push(String(herokuOptions[key]));
13
+ }
14
+ }
15
+
16
+ console.error(`== getting ENV ${envs}: heroku ${args.join(' ')}`);
11
17
 
12
- const cmd = `heroku config ${option}`;
13
- console.error(`== getting ENV ${envs}: ${cmd}`);
18
+ const result = execFileSync('heroku', args);
19
+ const output = result.toString();
20
+ let config;
21
+ try {
22
+ config = JSON.parse(output);
23
+ } catch (e) {
24
+ console.error(output);
25
+ process.exit(1);
26
+ }
14
27
 
15
28
  const herokuEnvs = {};
16
- for (let line of execSync(cmd).toString().split(/\n/)) {
17
- const [, key, value] = line.match(/^([A-Z\d_]+):\s+(.+)$/) || [];
18
- if (key && value && envs.includes(key)) {
19
- herokuEnvs[key] = value;
29
+ for (const key of envs) {
30
+ if (config[key] !== undefined) {
31
+ herokuEnvs[key] = config[key];
20
32
  }
21
33
  }
22
34
  return herokuEnvs;
@@ -1,25 +0,0 @@
1
- name: app-test
2
-
3
- on:
4
- push:
5
- branches: ['main']
6
- pull_request:
7
- branches: ['*']
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
-
13
- strategy:
14
- matrix:
15
- node-version: [22.x, 24.x]
16
-
17
- steps:
18
- - uses: actions/checkout@v4
19
- - name: Use Node.js ${{ matrix.node-version }}
20
- uses: actions/setup-node@v4
21
- with:
22
- node-version: ${{ matrix.node-version }}
23
- cache: 'npm'
24
- - run: npm ci
25
- - run: NODE_ENV=test npm run test
package/.prettierrc.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "arrowParens": "avoid",
3
- "singleQuote": true,
4
- "jsxSingleQuote": true,
5
- "trailingComma": "none"
6
- }