-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dgtlntv/pre-inquirer
Move to libraries and node shimming
- Loading branch information
Showing
42 changed files
with
7,813 additions
and
1,890 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
diff --git a/lib/platform-shims/browser.mjs b/lib/platform-shims/browser.mjs | ||
index 5f8ec61f449a10d0281268b409cf026da6468333..f445dff7ee396c4c589af8eab2040e12cba3da00 100644 | ||
--- a/lib/platform-shims/browser.mjs | ||
+++ b/lib/platform-shims/browser.mjs | ||
@@ -1,95 +1,94 @@ | ||
/* eslint-disable no-unused-vars */ | ||
-'use strict'; | ||
+"use strict" | ||
|
||
-import cliui from 'https://unpkg.com/[email protected]/index.mjs'; // eslint-disable-line | ||
-import Parser from 'https://unpkg.com/[email protected]/browser.js'; // eslint-disable-line | ||
-import {getProcessArgvBin} from '../../build/lib/utils/process-argv.js'; | ||
-import {YError} from '../../build/lib/yerror.js'; | ||
+import cliui from "https://unpkg.com/[email protected]/index.mjs" // eslint-disable-line | ||
+import Parser from "https://unpkg.com/[email protected]/browser.js" // eslint-disable-line | ||
+import { getProcessArgvBin } from "../../build/lib/utils/process-argv.js" | ||
+import { YError } from "../../build/lib/yerror.js" | ||
|
||
-const REQUIRE_ERROR = 'require is not supported in browser'; | ||
-const REQUIRE_DIRECTORY_ERROR = | ||
- 'loading a directory of commands is not supported in browser'; | ||
+const REQUIRE_ERROR = "require is not supported in browser" | ||
+const REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported in browser" | ||
|
||
export default { | ||
- assert: { | ||
- notStrictEqual: (a, b) => { | ||
- // noop. | ||
+ assert: { | ||
+ notStrictEqual: (a, b) => { | ||
+ // noop. | ||
+ }, | ||
+ strictEqual: (a, b) => { | ||
+ // noop. | ||
+ }, | ||
}, | ||
- strictEqual: (a, b) => { | ||
- // noop. | ||
+ cliui, | ||
+ findUp: () => undefined, | ||
+ getEnv: (key) => { | ||
+ // There is no environment in browser: | ||
+ return undefined | ||
}, | ||
- }, | ||
- cliui, | ||
- findUp: () => undefined, | ||
- getEnv: key => { | ||
- // There is no environment in browser: | ||
- return undefined; | ||
- }, | ||
- inspect: console.log, | ||
- getCallerFile: () => { | ||
- throw new YError(REQUIRE_DIRECTORY_ERROR); | ||
- }, | ||
- getProcessArgvBin, | ||
- mainFilename: 'yargs', | ||
- Parser, | ||
- path: { | ||
- basename: str => str, | ||
- dirname: str => str, | ||
- extname: str => str, | ||
- relative: str => str, | ||
- }, | ||
- process: { | ||
- argv: () => [], | ||
- cwd: () => '', | ||
- emitWarning: (warning, name) => {}, | ||
- execPath: () => '', | ||
- // exit is noop browser: | ||
- exit: () => {}, | ||
- nextTick: cb => { | ||
- // eslint-disable-next-line no-undef | ||
- window.setTimeout(cb, 1); | ||
+ inspect: console.log, | ||
+ getCallerFile: () => { | ||
+ throw new YError(REQUIRE_DIRECTORY_ERROR) | ||
}, | ||
- stdColumns: 80, | ||
- }, | ||
- readFileSync: () => { | ||
- return ''; | ||
- }, | ||
- require: () => { | ||
- throw new YError(REQUIRE_ERROR); | ||
- }, | ||
- requireDirectory: () => { | ||
- throw new YError(REQUIRE_DIRECTORY_ERROR); | ||
- }, | ||
- stringWidth: str => { | ||
- return [...str].length; | ||
- }, | ||
- // TODO: replace this with y18n once it's ported to ESM: | ||
- y18n: { | ||
- __: (...str) => { | ||
- if (str.length === 0) return ''; | ||
- const args = str.slice(1); | ||
- return sprintf(str[0], ...args); | ||
+ getProcessArgvBin, | ||
+ mainFilename: "yargs", | ||
+ Parser, | ||
+ path: { | ||
+ basename: (str) => str, | ||
+ dirname: (str) => str, | ||
+ extname: (str) => str, | ||
+ relative: (str) => str, | ||
}, | ||
- __n: (str1, str2, count, ...args) => { | ||
- if (count === 1) { | ||
- return sprintf(str1, ...args); | ||
- } else { | ||
- return sprintf(str2, ...args); | ||
- } | ||
+ process: { | ||
+ argv: () => [], | ||
+ cwd: () => "", | ||
+ emitWarning: (warning, name) => {}, | ||
+ execPath: () => "", | ||
+ // exit is noop browser: | ||
+ exit: () => {}, | ||
+ nextTick: (cb) => { | ||
+ // eslint-disable-next-line no-undef | ||
+ window.setTimeout(cb, 1) | ||
+ }, | ||
+ stdColumns: 80, | ||
}, | ||
- getLocale: () => { | ||
- return 'en_US'; | ||
+ readFileSync: () => { | ||
+ return "" | ||
}, | ||
- setLocale: () => {}, | ||
- updateLocale: () => {}, | ||
- }, | ||
-}; | ||
+ require: () => { | ||
+ throw new YError(REQUIRE_ERROR) | ||
+ }, | ||
+ requireDirectory: () => { | ||
+ throw new YError(REQUIRE_DIRECTORY_ERROR) | ||
+ }, | ||
+ stringWidth: (str) => { | ||
+ return [...str].length | ||
+ }, | ||
+ // TODO: replace this with y18n once it's ported to ESM: | ||
+ y18n: { | ||
+ __: (...str) => { | ||
+ if (str.length === 0) return "" | ||
+ const args = str.slice(1) | ||
+ return sprintf(str[0], ...args) | ||
+ }, | ||
+ __n: (str1, str2, count, ...args) => { | ||
+ if (count === 1) { | ||
+ return sprintf(str1, ...args) | ||
+ } else { | ||
+ return sprintf(str2, ...args) | ||
+ } | ||
+ }, | ||
+ getLocale: () => { | ||
+ return "en_US" | ||
+ }, | ||
+ setLocale: () => {}, | ||
+ updateLocale: () => {}, | ||
+ }, | ||
+} | ||
|
||
function sprintf(_str, ...args) { | ||
- let str = ''; | ||
- const split = _str.split('%s'); | ||
- split.forEach((token, i) => { | ||
- str += `${token}${split[i + 1] !== undefined && args[i] ? args[i] : ''}`; | ||
- }); | ||
- return str; | ||
+ let str = "" | ||
+ const split = _str.split("%s") | ||
+ split.forEach((token, i) => { | ||
+ str += `${token}${split[i + 1] !== undefined && args[i] ? args[i] : ""}` | ||
+ }) | ||
+ return str | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nodeLinker: node-modules | ||
|
||
yarnPath: .yarn/releases/yarn-4.4.0.cjs |
Oops, something went wrong.