source: frontend/node_modules/yargs/lib/platform-shims/esm.mjs

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.7 KB
Line 
1'use strict'
2
3import { notStrictEqual, strictEqual } from 'assert'
4import cliui from 'cliui'
5import escalade from 'escalade/sync'
6import { format, 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 execPath: () => process.execPath,
49 exit: process.exit,
50 nextTick: process.nextTick,
51 stdColumns: typeof process.stdout.columns !== 'undefined' ? process.stdout.columns : null
52 },
53 readFileSync,
54 require: () => {
55 throw new YError(REQUIRE_ERROR)
56 },
57 requireDirectory: () => {
58 throw new YError(REQUIRE_DIRECTORY_ERROR)
59 },
60 stringWidth: (str) => {
61 return [...str].length
62 },
63 y18n: y18n({
64 directory: resolve(__dirname, '../../../locales'),
65 updateFiles: false
66 })
67}
Note: See TracBrowser for help on using the repository browser.