source: trip-planner-front/node_modules/yargs/lib/platform-shims/esm.mjs@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1'use strict'
2
3import { notStrictEqual, strictEqual } from 'assert'
4import cliui from 'cliui'
5import escalade from 'escalade/sync'
6import { inspect } from 'util'
7import { readFileSync } from 'fs'
8import { fileURLToPath } from 'url';
9import Parser from 'yargs-parser'
10import { basename, dirname, extname, relative, resolve } from 'path'
11import { getProcessArgvBin } from '../../build/lib/utils/process-argv.js'
12import { YError } from '../../build/lib/yerror.js'
13import y18n from 'y18n'
14
15const REQUIRE_ERROR = 'require is not supported by ESM'
16const REQUIRE_DIRECTORY_ERROR = 'loading a directory of commands is not supported yet for ESM'
17
18const mainFilename = fileURLToPath(import.meta.url).split('node_modules')[0]
19const __dirname = fileURLToPath(import.meta.url)
20
21export default {
22 assert: {
23 notStrictEqual,
24 strictEqual
25 },
26 cliui,
27 findUp: escalade,
28 getEnv: (key) => {
29 return process.env[key]
30 },
31 inspect,
32 getCallerFile: () => {
33 throw new YError(REQUIRE_DIRECTORY_ERROR)
34 },
35 getProcessArgvBin,
36 mainFilename: mainFilename || process.cwd(),
37 Parser,
38 path: {
39 basename,
40 dirname,
41 extname,
42 relative,
43 resolve
44 },
45 process: {
46 argv: () => process.argv,
47 cwd: process.cwd,
48 emitWarning: (warning, type) => process.emitWarning(warning, type),
49 execPath: () => process.execPath,
50 exit: process.exit,
51 nextTick: process.nextTick,
52 stdColumns: typeof process.stdout.columns !== 'undefined' ? process.stdout.columns : null
53 },
54 readFileSync,
55 require: () => {
56 throw new YError(REQUIRE_ERROR)
57 },
58 requireDirectory: () => {
59 throw new YError(REQUIRE_DIRECTORY_ERROR)
60 },
61 stringWidth: (str) => {
62 return [...str].length
63 },
64 y18n: y18n({
65 directory: resolve(__dirname, '../../../locales'),
66 updateFiles: false
67 })
68}
Note: See TracBrowser for help on using the repository browser.