Skip to content
Permalink
Browse files
fix: expose helpers for legacy versions of Node.js (#1801)
  • Loading branch information
bcoe committed Nov 15, 2020
1 parent cb01c98 commit 107deaa4f68b7bc3f2386041e1f4fe0272b29c0a
Showing with 35 additions and 15 deletions.
  1. +1 −0 .eslintignore
  2. +0 −10 helpers.mjs
  3. +10 −0 helpers/helpers.mjs
  4. +14 −0 helpers/index.js
  5. +3 −0 helpers/package.json
  6. +5 −3 package.json
  7. +1 −1 test/esm/helpers.mjs
  8. +1 −1 yargs
@@ -1,3 +1,4 @@
build/
test/
example/
helpers/

This file was deleted.

@@ -0,0 +1,10 @@
import {applyExtends as _applyExtends} from '../build/lib/utils/apply-extends.js';
import {hideBin} from '../build/lib/utils/process-argv.js';
import Parser from 'yargs-parser';
import shim from '../lib/platform-shims/esm.mjs';

const applyExtends = (config, cwd, mergeExtends) => {
return _applyExtends(config, cwd, mergeExtends, shim);
};

export {applyExtends, hideBin, Parser};
@@ -0,0 +1,14 @@
const {
applyExtends,
cjsPlatformShim,
Parser,
processArgv,
} = require('../build/index.cjs');

module.exports = {
applyExtends: (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
},
hideBin: processArgv.hideBin,
Parser,
};
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
@@ -12,8 +12,8 @@
"./index.cjs"
],
"./helpers": {
"import": "./helpers.mjs",
"require": "./yargs"
"import": "./helpers/helpers.mjs",
"require": "./helpers/index.js"
},
"./yargs": [
{
@@ -33,7 +33,8 @@
"files": [
"browser.mjs",
"index.cjs",
"helpers.mjs",
"helpers/*.js",
"helpers/*",
"index.mjs",
"yargs",
"build",
@@ -99,6 +100,7 @@
"standardx": {
"ignore": [
"build",
"helpers",
"**/example/**",
"**/platform-shims/esm.mjs"
]
@@ -1,7 +1,7 @@
'use strict';

import * as assert from 'assert';
import {applyExtends, hideBin, Parser} from '../../helpers.mjs';
import {applyExtends, hideBin, Parser} from '../../helpers/helpers.mjs';
import {describe, it} from 'mocha';

describe('helpers', () => {
2 yargs
@@ -1,5 +1,5 @@
// TODO: consolidate on using a helpers file at some point in the future, which
// is the approach currently used to export Parser and applyExtends for ESM:
// is the approach currently used to export Parser and applyExtends for ESM:
const {applyExtends, cjsPlatformShim, Parser, Yargs, processArgv} = require('./build/index.cjs')
Yargs.applyExtends = (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim)

0 comments on commit 107deaa

Please sign in to comment.