├── .babelrc
├── .eslintrc.cjs
├── .github
├── actions
│ └── checkout
│ │ └── action.yml
└── workflows
│ ├── test.yml
│ └── versioning.yml
├── .gitignore
├── .npmignore
├── .nycrc
├── .releaserc
├── .run
├── Code Coverage.run.xml
├── Demo 3.run.xml
├── Demo 5.run.xml
├── Get to-esm help.run.xml
├── demo-docs.run.xml
├── demo.run.xml
├── demo_terminal_esm (1).run.xml
├── index.js.run.xml
└── test.run.xml
├── CHANGELOG.md
├── INFO.md
├── README-OLD.md
├── README.md
├── bump.js
├── docs
├── README.md
├── benefits
│ └── benefits.md
├── directives
│ └── directives.md
├── examples
│ ├── automatically-write-an-importmap-within-html-files.md
│ ├── convert-files-with-patterns.md
│ ├── generate-code-for-the-browser.md
│ ├── generate-code-into-a-dedicated-directory.md
│ ├── generate-esm-code.md
│ ├── img_1.png
│ └── remove-automatic-generated-header.md
├── ideas
│ ├── conventions-for-writing-code-for-both-esm-and-cjs.md
│ ├── create-hybrid-library-with-to-esm-supporting-the-browser.md
│ ├── create-hybrid-library-with-to-esm.md
│ ├── thoughts.md
│ └── working-with-both-CJS-and-ESM.md
├── images
│ ├── convert-to-esm-1.gif
│ ├── img.png
│ ├── img_1.png
│ ├── img_2.png
│ └── img_3.png
└── options
│ ├── via-cli.md
│ └── via-config-file.md
├── eslint-runtime.js
├── example
├── .toesm.cjs
├── cjs
│ ├── another.html
│ ├── constants
│ │ ├── constants.cjs
│ │ └── constants.json
│ ├── contexts-def.cjs
│ ├── demo-1.cjs
│ ├── demo-2.cjs
│ ├── demo-3.cjs
│ ├── demo-directives.cjs
│ ├── demo-test-15.cjs
│ ├── dep-1.cjs
│ ├── dep-2.cjs
│ ├── dep-3.js
│ ├── input-less.js
│ └── more
│ │ ├── again.html
│ │ ├── dep-1.cjs
│ │ ├── dep-5.js
│ │ ├── dep-6.js
│ │ └── input-more.js
├── esm2
│ └── demo-1.mjs
├── index.html
└── other.html
├── index.cjs
├── license.txt
├── lid-generator.cjs
├── markdown.json
├── package-lock.json
├── package.json
├── src
├── converter.cjs
├── regexes
│ ├── to-esm-add.txt
│ ├── to-esm-remove.txt
│ └── to-esm-skip.txt
└── type-def.cjs
├── test
├── 1-unit.cjs
├── 2-integration-cli.cjs
├── 3-integration.cjs
├── 4- end-to-end.cjs
├── __test__.md
├── assets
│ ├── expect
│ │ ├── ana-logger.mjs
│ │ ├── analogger-test.mjs
│ │ ├── case-1
│ │ │ ├── imported
│ │ │ │ ├── define-property
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-accessor-descriptor
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-data-descriptor
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-descriptor
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-number
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── kind-of
│ │ │ │ │ └── index.mjs
│ │ │ │ └── window-size
│ │ │ │ │ ├── index.mjs
│ │ │ │ │ └── utils.mjs
│ │ │ ├── models
│ │ │ │ └── example-1
│ │ │ │ │ └── more
│ │ │ │ │ ├── contexts-def.mjs
│ │ │ │ │ └── demo.mjs
│ │ │ └── src
│ │ │ │ ├── ana-logger.mjs
│ │ │ │ └── constants.mjs
│ │ ├── case-2
│ │ │ ├── models
│ │ │ │ └── example-1
│ │ │ │ │ └── more
│ │ │ │ │ ├── contexts-def.mjs
│ │ │ │ │ └── demo.mjs
│ │ │ ├── node_modules
│ │ │ │ ├── define-property
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-accessor-descriptor
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-data-descriptor
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-descriptor
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── is-number
│ │ │ │ │ └── index.mjs
│ │ │ │ ├── kind-of
│ │ │ │ │ └── index.mjs
│ │ │ │ └── window-size
│ │ │ │ │ ├── index.mjs
│ │ │ │ │ └── utils.mjs
│ │ │ └── src
│ │ │ │ ├── ana-logger.mjs
│ │ │ │ └── constants.mjs
│ │ ├── case-3
│ │ │ ├── common
│ │ │ │ ├── common-feature-exchanger.mjs
│ │ │ │ ├── data-exchanger.mjs
│ │ │ │ └── specificities.mjs
│ │ │ ├── demo-test-34.mjs
│ │ │ └── node_modules
│ │ │ │ ├── commondir
│ │ │ │ └── index.mjs
│ │ │ │ └── to-ansi
│ │ │ │ └── index.mjs
│ │ ├── case-4
│ │ │ ├── _root
│ │ │ │ └── projects
│ │ │ │ │ └── to-esm
│ │ │ │ │ └── test
│ │ │ │ │ └── assets
│ │ │ │ │ └── given
│ │ │ │ │ └── my-test-class.mjs
│ │ │ └── demo-test-43.mjs
│ │ ├── demo-bad-syntax.mjs
│ │ ├── demo-test-10.mjs
│ │ ├── demo-test-11.mjs
│ │ ├── demo-test-12.mjs
│ │ ├── demo-test-13-bis.mjs
│ │ ├── demo-test-13.mjs
│ │ ├── demo-test-14.mjs
│ │ ├── demo-test-16.mjs
│ │ ├── demo-test-17.mjs
│ │ ├── demo-test-18.mjs
│ │ ├── demo-test-19.mjs
│ │ ├── demo-test-2.mjs
│ │ ├── demo-test-20.mjs
│ │ ├── demo-test-21.mjs
│ │ ├── demo-test-22.mjs
│ │ ├── demo-test-23.mjs
│ │ ├── demo-test-24.mjs
│ │ ├── demo-test-25.mjs
│ │ ├── demo-test-26.mjs
│ │ ├── demo-test-27.mjs
│ │ ├── demo-test-28.mjs
│ │ ├── demo-test-29.min.mjs
│ │ ├── demo-test-3.mjs
│ │ ├── demo-test-30.mjs
│ │ ├── demo-test-31.mjs
│ │ ├── demo-test-32.mjs
│ │ ├── demo-test-33.mjs
│ │ ├── demo-test-34.mjs
│ │ ├── demo-test-35.mjs
│ │ ├── demo-test-36.mjs
│ │ ├── demo-test-37.mjs
│ │ ├── demo-test-38.mjs
│ │ ├── demo-test-39.mjs
│ │ ├── demo-test-4.mjs
│ │ ├── demo-test-40.mjs
│ │ ├── demo-test-41.mjs
│ │ ├── demo-test-42.mjs
│ │ ├── demo-test-43.mjs
│ │ ├── demo-test-44.mjs
│ │ ├── demo-test-45.mjs
│ │ ├── demo-test-46.mjs
│ │ ├── demo-test-50.mjs
│ │ ├── demo-test-51.mjs
│ │ ├── demo-test-52.mjs
│ │ ├── demo-test-53.mjs
│ │ ├── demo-test-54.mjs
│ │ ├── demo-test-55.mjs
│ │ ├── demo-test-56.mjs
│ │ ├── demo-test-57.mjs
│ │ ├── demo-test-58.mjs
│ │ ├── demo-test-6.mjs
│ │ ├── demo-test-7.mjs
│ │ ├── demo-test-75.mjs
│ │ ├── demo-test-76.mjs
│ │ ├── demo-test-77.mjs
│ │ ├── demo-test-78.mjs
│ │ ├── demo-test-79.mjs
│ │ ├── demo-test-8.mjs
│ │ ├── demo-test-80.mjs
│ │ ├── demo-test-81.mjs
│ │ ├── demo-test-82.js
│ │ ├── demo-test-9.mjs
│ │ ├── demo-test-x.mjs
│ │ ├── demo-test.min.mjs
│ │ ├── demo-test.mjs
│ │ ├── dump-demo-test-removeResidue.js
│ │ ├── html-1
│ │ │ └── index.html
│ │ ├── html-2
│ │ │ └── index-2.html
│ │ ├── index-2.html
│ │ ├── index.html
│ │ ├── other.html
│ │ ├── package-2.json
│ │ ├── package-3.json
│ │ ├── package-json
│ │ │ ├── package-1.json
│ │ │ ├── package-2.json
│ │ │ ├── package-3.json
│ │ │ └── package-4.json
│ │ ├── package.json
│ │ └── rgb-hex-cjs-index.mjs
│ ├── given
│ │ ├── .toesm-invalid.json
│ │ ├── .toesm-nohtml-pattern.json
│ │ ├── .toesm-replace-modules.json
│ │ ├── .toesm.json
│ │ ├── ana-logger.cjs
│ │ ├── analogger
│ │ │ ├── analogger-test.cjs
│ │ │ └── constants.cjs
│ │ ├── case-1
│ │ │ └── deep1
│ │ │ │ └── deep2
│ │ │ │ └── deep3
│ │ │ │ ├── models
│ │ │ │ └── example-1
│ │ │ │ │ └── more
│ │ │ │ │ ├── contexts-def.cjs
│ │ │ │ │ ├── demo.cjs
│ │ │ │ │ └── something
│ │ │ │ │ ├── dummy.cjs
│ │ │ │ │ ├── dummy.cjs.js
│ │ │ │ │ └── dummy.js
│ │ │ │ └── src
│ │ │ │ ├── ana-logger.cjs
│ │ │ │ └── constants.cjs
│ │ ├── case-2
│ │ │ └── plan-1
│ │ │ │ ├── models
│ │ │ │ └── example-1
│ │ │ │ │ └── more
│ │ │ │ │ ├── contexts-def.cjs
│ │ │ │ │ ├── demo.cjs
│ │ │ │ │ └── something
│ │ │ │ │ ├── dummy.cjs
│ │ │ │ │ ├── dummy.cjs.js
│ │ │ │ │ └── dummy.js
│ │ │ │ └── src
│ │ │ │ ├── ana-logger.cjs
│ │ │ │ └── constants.cjs
│ │ ├── common
│ │ │ ├── common-feature-exchanger.cjs
│ │ │ ├── data-exchanger.cjs
│ │ │ └── specificities.cjs
│ │ ├── demo-bad-syntax.cjs
│ │ ├── demo-generic.js
│ │ ├── demo-test-10.cjs
│ │ ├── demo-test-11.cjs
│ │ ├── demo-test-12.cjs
│ │ ├── demo-test-13-bis.cjs
│ │ ├── demo-test-13.cjs
│ │ ├── demo-test-14.cjs
│ │ ├── demo-test-15.cjs
│ │ ├── demo-test-16.cjs
│ │ ├── demo-test-17.cjs
│ │ ├── demo-test-17.mjs
│ │ ├── demo-test-18.cjs
│ │ ├── demo-test-19.cjs
│ │ ├── demo-test-2.cjs
│ │ ├── demo-test-20.cjs
│ │ ├── demo-test-21.cjs
│ │ ├── demo-test-22.cjs
│ │ ├── demo-test-23.cjs
│ │ ├── demo-test-24.cjs
│ │ ├── demo-test-25.cjs
│ │ ├── demo-test-26.cjs
│ │ ├── demo-test-27.cjs
│ │ ├── demo-test-28.cjs
│ │ ├── demo-test-28.mjs
│ │ ├── demo-test-29.cjs
│ │ ├── demo-test-3.cjs
│ │ ├── demo-test-30.cjs
│ │ ├── demo-test-31.cjs
│ │ ├── demo-test-32.cjs
│ │ ├── demo-test-33.cjs
│ │ ├── demo-test-34.cjs
│ │ ├── demo-test-35.cjs
│ │ ├── demo-test-36.cjs
│ │ ├── demo-test-37.cjs
│ │ ├── demo-test-38.cjs
│ │ ├── demo-test-39.js
│ │ ├── demo-test-4.cjs
│ │ ├── demo-test-40.cjs
│ │ ├── demo-test-41.cjs
│ │ ├── demo-test-42.cjs
│ │ ├── demo-test-43.cjs
│ │ ├── demo-test-44.cjs
│ │ ├── demo-test-45.mjs
│ │ ├── demo-test-46.mjs
│ │ ├── demo-test-5.cjs
│ │ ├── demo-test-50.cjs
│ │ ├── demo-test-51.cjs
│ │ ├── demo-test-52.cjs
│ │ ├── demo-test-53.cjs
│ │ ├── demo-test-54.cjs
│ │ ├── demo-test-55.cjs
│ │ ├── demo-test-56.cjs
│ │ ├── demo-test-57.cjs
│ │ ├── demo-test-58.cjs
│ │ ├── demo-test-6.cjs
│ │ ├── demo-test-7.cjs
│ │ ├── demo-test-75.cjs
│ │ ├── demo-test-76.cjs
│ │ ├── demo-test-77.cjs
│ │ ├── demo-test-78.cjs
│ │ ├── demo-test-79.cjs
│ │ ├── demo-test-8.cjs
│ │ ├── demo-test-80.cjs
│ │ ├── demo-test-81.cjs
│ │ ├── demo-test-9.cjs
│ │ ├── demo-test-x.cjs
│ │ ├── demo-test.cjs
│ │ ├── file1.cjs
│ │ ├── multi
│ │ │ ├── demo-bad-syntax.cjs
│ │ │ ├── demo-test-2.cjs
│ │ │ ├── demo-test-3.cjs
│ │ │ ├── demo-test-4.cjs
│ │ │ ├── demo-test-5.cjs
│ │ │ └── demo-test.cjs
│ │ ├── my-test-class-0.cjs
│ │ ├── my-test-class.cjs
│ │ ├── package-json
│ │ │ ├── package-1.json
│ │ │ ├── package-2.json
│ │ │ ├── package-3.json
│ │ │ ├── package-4.json
│ │ │ └── package-cases.json
│ │ └── set-output-extension
│ │ │ ├── demo-test-82.js
│ │ │ └── test2.js
│ ├── index-2.html
│ ├── index.html
│ └── other.html
├── node_modules
│ ├── .bin
│ │ ├── window-size
│ │ ├── window-size.cmd
│ │ └── window-size.ps1
│ ├── .package-lock.json
│ ├── commondir
│ │ ├── LICENSE
│ │ ├── example
│ │ │ └── dir.js
│ │ ├── index.js
│ │ ├── package.json
│ │ ├── readme.markdown
│ │ └── test
│ │ │ └── dirs.js
│ ├── define-property
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ └── package.json
│ ├── flatted
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── cjs
│ │ │ ├── index.js
│ │ │ └── package.json
│ │ ├── es.js
│ │ ├── esm.js
│ │ ├── esm
│ │ │ └── index.js
│ │ ├── index.js
│ │ ├── min.js
│ │ ├── package.json
│ │ ├── php
│ │ │ └── flatted.php
│ │ └── types.d.ts
│ ├── is-accessor-descriptor
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ └── package.json
│ ├── is-buffer
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ ├── package.json
│ │ └── test
│ │ │ └── basic.js
│ ├── is-data-descriptor
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ └── package.json
│ ├── is-descriptor
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ └── package.json
│ ├── is-number
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ ├── node_modules
│ │ │ └── kind-of
│ │ │ │ ├── LICENSE
│ │ │ │ ├── README.md
│ │ │ │ ├── index.js
│ │ │ │ └── package.json
│ │ └── package.json
│ ├── kind-of
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── index.js
│ │ └── package.json
│ ├── rgb-hex-cjs
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── license
│ │ ├── package.json
│ │ └── readme.md
│ ├── rgb-hex
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── license
│ │ ├── package.json
│ │ └── readme.md
│ ├── to-ansi
│ │ ├── .to-esm.cjs
│ │ ├── CHANGELOG.md
│ │ ├── README.md
│ │ ├── index.cjs
│ │ ├── index.mjs
│ │ ├── license.txt
│ │ └── package.json
│ └── window-size
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── cli.js
│ │ ├── index.js
│ │ ├── package.json
│ │ └── utils.js
├── package-lock.json
├── package.json
└── sandbox
│ ├── .gitignore
│ ├── example
│ ├── cjs
│ │ ├── contexts-def.cjs
│ │ ├── demo.cjs
│ │ └── something
│ │ │ ├── dummy.cjs
│ │ │ ├── dummy.cjs.js
│ │ │ └── dummy.js
│ ├── index.css
│ ├── index.css.map
│ ├── index.html
│ └── index.scss
│ ├── index.cjs
│ ├── package-lock.json
│ ├── package.json
│ └── test.js
└── todo.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "@babel/preset-env"
4 | ]
5 | }
--------------------------------------------------------------------------------
/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true,
4 | node: true
5 | },
6 | parserOptions: {
7 | "ecmaVersion": 2022
8 | },
9 | "ignorePatterns": ["example/**/*.*"],
10 | rules: {
11 | "comma-dangle": 0,
12 | "comma-style": ["error", "last"],
13 | "no-bitwise": "off",
14 | "no-console": "off",
15 | "no-nested-ternary": "off",
16 | "no-plusplus": "off",
17 | "prefer-const": "off",
18 | "spaced-comment": "off",
19 | "no-debugger": "error",
20 | "quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
21 | "semi": 2,
22 | "no-unused-vars": "error",
23 | "max-len": ["error", {code: 200}]
24 | }
25 | };
26 |
--------------------------------------------------------------------------------
/.github/actions/checkout/action.yml:
--------------------------------------------------------------------------------
1 | name: Version
2 | description: 'Version builds automatically'
3 | author: 'thimpat'
4 | runs:
5 | using: composite
6 | steps:
7 | - name: Welcome
8 | shell: powershell
9 | run: |
10 | echo Welcome
11 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 | env:
3 | TO_ESM_APP_NAME: "release/to-esm"
4 | GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
5 |
6 | on:
7 | push:
8 | branches:
9 | - "**"
10 | paths-ignore:
11 | - "**.md"
12 | - ".vscode/**"
13 | jobs:
14 | set-version:
15 | runs-on: [self-hosted]
16 | steps:
17 | - uses: actions/checkout@v2
18 | - name: Check out Git repository
19 | uses: thimpat/to-esm/.github/actions/checkout@main
20 | - name: Install dependencies
21 | shell: powershell
22 | run: npm install
23 | - name: Test
24 | shell: powershell
25 | run: |
26 | npm run lint
27 | npm test
28 |
--------------------------------------------------------------------------------
/.github/workflows/versioning.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 | env:
3 | TO_ESM_APP_NAME: "release/to-esm"
4 | on:
5 | push:
6 | branches:
7 | - main
8 | - ci
9 | paths-ignore:
10 | - "**.md"
11 | - ".vscode/**"
12 | jobs:
13 | set-version:
14 | runs-on: [self-hosted]
15 | steps:
16 | - uses: actions/checkout@v2
17 | - name: Check out Git repository
18 | uses: thimpat/to-esm/.github/actions/checkout@main
19 | - name: Install dependencies
20 | shell: powershell
21 | run: npm ci
22 | - name: Upgrade version
23 | shell: powershell
24 | run: |
25 | npm test
26 | npx semantic-release
27 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .vscode/*
2 | !.vscode/settings.json
3 | !.vscode/tasks.json
4 | !.vscode/launch.json
5 | !.vscode/extensions.json
6 | *.code-workspace
7 | .history/
8 | .idea/
9 | cmake-build-*/
10 | *.iws
11 | out/
12 | atlassian-ide-plugin.xml
13 | com_crashlytics_export_strings.xml
14 | crashlytics.properties
15 | crashlytics-build.properties
16 | fabric.properties
17 | logs
18 | *.log
19 | npm-debug.log*
20 | yarn-debug.log*
21 | yarn-error.log*
22 | lerna-debug.log*
23 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
24 | pids
25 | *.pid
26 | *.seed
27 | *.pid.lock
28 | lib-cov
29 | coverage
30 | *.lcov
31 | .nyc_output
32 | .grunt
33 | bower_components
34 | .lock-wscript
35 | build/Release
36 | node_modules/
37 | jspm_packages/
38 | web_modules/
39 | *.tsbuildinfo
40 | .npm
41 | .eslintcache
42 | .rpt2_cache/
43 | .rts2_cache_cjs/
44 | .rts2_cache_es/
45 | .rts2_cache_umd/
46 | .node_repl_history
47 | *.tgz
48 | .yarn-integrity
49 | .env
50 | .env.test
51 | .cache
52 | .parcel-cache
53 | .next
54 | .nuxt
55 | dist
56 | .cache/
57 | .vuepress/dist
58 | .serverless/
59 | .fusebox/
60 | .dynamodb/
61 | .tern-port
62 | .vscode-test
63 | .yarn/cache
64 | .yarn/unplugged
65 | .yarn/build-state.yml
66 | .yarn/install-state.gz
67 | .pnp.*
68 | .run/
69 | /docs
70 | /example
71 | /test
72 | /.github
73 | .nycrc
74 | .releaserc
75 | bump.js
76 | .babelrc
77 | .eslintrc.cjs
78 | build-docs/
79 | markdown.json
80 | README-OLD.md/
81 | debug/
82 |
83 | /CHANGELOG.md
84 | /INFO.md
85 | /README-OLD.md
86 | /todo.js
87 | /builder.bak.cjs
88 | /conversion-tester.cjs
89 | /conversion-tester.mjs
90 | /example1.cjs
91 | /lid-generator.cjs
92 | /testgen.cjs
93 | /bump.js
94 |
--------------------------------------------------------------------------------
/.nycrc:
--------------------------------------------------------------------------------
1 | {
2 | "lines": 84,
3 | "functions": 92,
4 | "branches": 65,
5 | "statements": 85,
6 | "reporter": [
7 | "json",
8 | "text-summary"
9 | ],
10 | "exclude": [
11 | "coverage/**",
12 | "docs/**",
13 | "test{,s}/**",
14 | "test{,-*}.{js,cjs,mjs,ts}",
15 | "lib/browser/**",
16 | "package-scripts.js",
17 | "scripts/**"
18 | ],
19 | "check-coverage": true
20 | }
--------------------------------------------------------------------------------
/.releaserc:
--------------------------------------------------------------------------------
1 | {
2 | "branches": ["test", "main", "next"],
3 | "dryRun": false,
4 | "ci": true,
5 | "debug": true,
6 | "plugins": [
7 | ["@semantic-release/commit-analyzer",
8 | {
9 | "preset": "angular",
10 | "releaseRules": [
11 | {"type": "docs", "scope":"README", "release": "patch"},
12 | {"type": "refactor", "release": "patch"},
13 | {"type": "style", "release": "patch"}
14 | ],
15 | "parserOpts": {
16 | "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
17 | }
18 | }],
19 | "@semantic-release/release-notes-generator",
20 | "@semantic-release/changelog",
21 | "@semantic-release/npm",
22 | ["@semantic-release/git", {
23 | "assets": ["package.json", "CHANGELOG.md"],
24 | "message": "To-esm Release: ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
25 | }]
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/.run/Code Coverage.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.run/Demo 3.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.run/Demo 5.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.run/Get to-esm help.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.run/demo-docs.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.run/demo.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.run/demo_terminal_esm (1).run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.run/index.js.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.run/test.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | project
11 |
12 | $PROJECT_DIR$/node_modules/mocha
13 | $PROJECT_DIR$
14 | true
15 | bdd
16 |
17 | DIRECTORY
18 | $PROJECT_DIR$/test
19 | false
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bump.js:
--------------------------------------------------------------------------------
1 | // Bump version 1.6.7 to 1.7.0 to fix semantic-versioning issue
2 | // Bump to version 2.0.x
3 | // Bump version to force update npm documentation
4 | // Bump version
5 |
--------------------------------------------------------------------------------
/docs/benefits/benefits.md:
--------------------------------------------------------------------------------
1 | 💊🔥🧨🔥💊💥
2 | ---
3 |
4 | ## Plus !heading
5 |
6 | > **Benefits:**
7 | >
8 | > - You do not need a sourcemap when working in development mode.
9 | > - You do not need to bundle your code in development.
10 | > - You benefit directly from your **browser caching ability** (No more bundling of shared libraries)
11 | > - The generated code looks like the original code.
12 | > - ...
13 |
14 |
--------------------------------------------------------------------------------
/docs/directives/directives.md:
--------------------------------------------------------------------------------
1 | 💉
2 |
3 | ## Directives !heading
4 |
5 |
6 |
7 | #### Directives allow more control over the generated code.
8 |
9 |
10 |
11 | ---
12 |
13 | ### Directives to replace code directly from the source.
14 |
15 | You can, if you want, also use some to-esm directives within the code.
16 | For instance, the code below will not appear when the target is a browser.
17 |
18 | ```javascript
19 | /** to-esm-browser: remove **/
20 | const path = require("path");
21 | const fs = require("fs");
22 | const os = require("os");
23 | /** to-esm-browser: end-remove **/
24 | ```
25 |
26 |
27 |
28 | ---
29 |
30 |
31 | ### Directives to add code to the source.
32 |
33 | It is also possible to add code.
34 |
35 | 📝 code.cjs ↴
36 | ```javascript
37 | /** to-esm-browser: add
38 | this.realConsoleLog("LogToFile is not supported in this environment. ")
39 | **/
40 | ```
41 |
42 | In this example, after conversion, the above code will become this:
43 |
44 | 📝 code.mjs (with target browser) ↴
45 | ```javascript
46 | this.realConsoleLog("LogToFile is not supported in this environment. ")
47 | ```
48 |
49 |
50 |
51 | ---
52 |
53 |
54 | ### Directives to ignore code during the parsing, so it won't be converted by mistake.
55 |
56 | ```javascript
57 | /** to-esm-all: skip **/
58 | console.log("Skip this");
59 | /** to-esm-all: end-skip **/
60 | ```
61 |
62 |
63 |
64 | ---
65 |
66 |
67 | ### Directives to keep the target file as it is.
68 |
69 | ```javascript
70 | /** to-esm-all: do-not-overwrite **/
71 | ```
72 |
73 | If the .mjs file already exists and contains this directive, it will not be overwritten.
74 |
--------------------------------------------------------------------------------
/docs/examples/automatically-write-an-importmap-within-html-files.md:
--------------------------------------------------------------------------------
1 | 📋
2 |
3 | #### Generate some importmap within html files !heading
4 |
5 | > --html < pattern | html >
6 |
7 | ```shell
8 | # Generates => 📝 ./demo.mjs & update index.html
9 | $> to-esm example/cjs/demo.cjs --html index.html
10 | ```
11 |
12 | ---
13 |
14 | ###### An import map will allow writing imports like this
15 |
16 | ```javascript
17 | import rgbhex from "rgb-hex"
18 | ```
19 |
20 |
21 | ###### instead of
22 |
23 | ```javascript
24 | import rgbhex from "../../../path/to/rgb-hex.mjs"
25 | ```
26 |
27 | ---
28 |
29 | ###### Click on the arrow to expand or collapse
30 | HTML importmap section
31 |
32 |
33 |
34 |
35 | ###### Before
36 | 📝 index.html ↴
37 | ```html
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | ```
47 |
48 | ###### After
49 | ```html
50 |
51 |
52 |
53 |
60 |
61 |
62 |
63 |
64 |
65 | ```
66 |
67 |
68 |
69 | ---
70 |
71 | importmap allows some more elaborated setups where third party caching will be entirely handled by the browser.
72 |
73 |
--------------------------------------------------------------------------------
/docs/examples/convert-files-with-patterns.md:
--------------------------------------------------------------------------------
1 | 📋
2 |
3 | #### Convert files with patterns !heading
4 |
5 | You can have multiple files converted in one go. It can be helpful if some files are not connected.
6 |
7 | ```shell
8 |
9 | $> to-esm --input="example/cjs/*.?(c)js" --output=example/esm/
10 |
11 | ```
12 |
13 |
14 |
--------------------------------------------------------------------------------
/docs/examples/generate-code-into-a-dedicated-directory.md:
--------------------------------------------------------------------------------
1 | 📋
2 |
3 | #### Generate code into a dedicated directory !heading
4 |
5 | > --output < folder >
6 |
7 | ```shell
8 | # 💻 < Command
9 | $> to-esm example/cjs/input.cjs --output generated/esm
10 | ```
11 |
12 | ---
13 |
14 |
15 | ###### Click on the arrow to expand or collapse
16 | ⏳ Before...
17 |
18 | ```
19 | 📁project ⇽ Ran from here
20 | │
21 | └───📁example
22 | │ │
23 | │ └───📁code
24 | │ │ 📝 library.js
25 | │ │ 📝 demo.js ⇽ 🚩
26 | │ │ ...
27 | ```
28 |
29 |
30 |
31 |
32 |
33 | ⌛ After...
34 |
35 | ```
36 | 📁project
37 | │
38 | └───📁example
39 | │ │
40 | │ └───📁code
41 | │ │ 📝 library.js
42 | │ │ 📝 demo.js
43 | │ │ ...
44 | │
45 | └───📁generated ⇽ 🚩
46 | │ └───📁esm
47 | │ └───📁example
48 | │ └───📁code
49 | │ 📝 library.mjs ⇽ 🚩
50 | │ 📝 demo.mjs ⇽
51 | │ ...
52 | ```
53 |
54 |
55 |
56 |
57 |
58 | ⌛ Check...
59 |
60 | ##### Checking the conversion has succeeded
61 |
62 | ```shell
63 | node generated/esm/example/code/demo.mjs
64 | ```
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/docs/examples/generate-esm-code.md:
--------------------------------------------------------------------------------
1 | 📋
2 |
3 | #### Generate ESM code !heading
4 |
5 | To generate an **.mjs**(ES module) file from a **.js** file do:
6 |
7 | ---
8 |
9 | ```shell
10 | # 💻 < Command
11 | $> to-esm example/cjs/input.js
12 | ```
13 |
14 | > 🚫
15 | > **NOTE: to-esm should run from the project root folder.**
16 |
17 |
18 | ---
19 |
20 |
21 | ###### Click on the arrow to expand or collapse
22 |
23 | ⏳ Before...
24 |
25 | ```
26 | 📁project ⇽ Ran from here
27 | │
28 | └───📁example
29 | │ │
30 | │ └───📁code
31 | │ │ 📝 library.js
32 | │ │ 📝 demo.js ⇽
33 | │ │ ...
34 | │
35 | ```
36 |
37 | 📝 _library.js_ ↴
38 | ```javascript
39 | function hi()
40 | {
41 | console.log(`I wanted to say hi!`)
42 | }
43 | module.exports = hi;
44 | ```
45 |
46 | 📝 _demo.js_ ↴
47 | ```javascript
48 | const hi = require("./library.js");
49 | hi();
50 | ```
51 |
52 | **./demo.js => ./demo.mjs 📝**
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | ⌛ After...
61 |
62 | ```
63 | 📁project
64 | │
65 | └───📁example
66 | │ │
67 | │ └───📁code
68 | │ │ 📄 library.js
69 | │ │ 📄 demo.js
70 | │ │ 📝 library.mjs ⇽
71 | │ │ ...
72 | │
73 | └ 📝 demo.mjs ⇽
74 | ```
75 |
76 | 📝 _library.js_ ↴
77 | ```javascript
78 | function hi()
79 | {
80 | console.log(`I wanted to say hi!`)
81 | }
82 |
83 | export default hi;
84 | ```
85 |
86 | 📝 _demo.js_ ↴
87 | ```javascript
88 | import hi from "./example/code/library.mjs";
89 | hi();
90 | ```
91 |
92 | to-esm will convert the entry point inside the working
93 | directory. The others will depend on the source location.
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/docs/examples/img_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/docs/examples/img_1.png
--------------------------------------------------------------------------------
/docs/examples/remove-automatic-generated-header.md:
--------------------------------------------------------------------------------
1 | 📋
2 |
3 | #### Remove automatic generated header !heading
4 |
5 | > --noheader
6 |
7 |
8 | ```shell
9 | # 💻 < Command
10 | $> to-esm example/cjs/input.cjs --output generated --noheader
11 | ```
12 | ---
13 |
14 |
15 | ⌛ --noheader in action
16 |
17 | #### ⏳ - Without the --noheader option
18 |
19 | ```javascript
20 | /**
21 | * DO NOT EDIT THIS FILE DIRECTLY.
22 | * This file is generated following the conversion of
23 | * [./example/code/demo.js]{@link ./example/code/demo.js}
24 | *
25 | **/
26 | import hi from "./example/code/library.mjs";
27 | hi();
28 | ```
29 |
30 |
31 |
32 | #### ⌛ With the --noheader option
33 |
34 | ```javascript
35 | import hi from "./example/code/library.mjs";
36 | hi();
37 | ```
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/docs/ideas/conventions-for-writing-code-for-both-esm-and-cjs.md:
--------------------------------------------------------------------------------
1 | 💡
2 | ## Some conventions to write code for both CommonJs and ES Modules
3 |
4 | Here are a few guides to writing code easily convertible.
5 |
6 |
7 | ### Use named exports
8 |
9 | For having the best compatibility between the two systems, it is best to use named exports.
10 |
11 |
12 | Replace structure like:
13 |
14 | ```javascript
15 |
16 | module.exports = {
17 | TABLE1: ...,
18 | TABLE2: ...,
19 | otherKey: ...
20 | }
21 | ```
22 |
23 | with:
24 |
25 | ```javascript
26 |
27 | module.exports.TABLE1 = ...;
28 | module.exports.TABLE2 = ...;
29 | module.exports.otherKey = ...;
30 | ```
31 |
32 | Or, if you want to provide a default export too:
33 |
34 | ```javascript
35 | // Default export
36 | module.exports = {
37 | TABLE1, TABLE2, ...
38 | }
39 |
40 | // Named export
41 | module.exports.TABLE1 = ...;
42 | module.exports.TABLE2 = ...;
43 | module.exports.otherKey = ...;
44 | ```
45 |
46 |
47 | ### Use simple "require"
48 |
49 | Rather than using requires like below (or more complex forms)
50 |
51 | 🤏 ↴
52 | ```javascript
53 | const Something = require("electron-data-exchanger").myThing;
54 | const anything = require("electron-data-exchanger")(...);
55 | ```
56 |
57 | Which may introduce temporary variables (_toesmTemp1)
58 |
59 | ```javascript
60 | import _toesmTemp1 from "electron-data-exchanger";
61 | const Something = _toesmTemp1.myThing;
62 | ```
63 |
64 | It is best to have them uncomplicated, so the conversion is straightforward
65 |
66 | 👍 ↴
67 | ```javascript
68 | const MySomething = require("electron-data-exchanger");
69 | const myAnything = require("electron-data-exchanger");
70 |
71 | // ... The code that uses what was required
72 | ```
73 |
74 |
--------------------------------------------------------------------------------
/docs/ideas/thoughts.md:
--------------------------------------------------------------------------------
1 | 💡
2 |
3 | ### Some thoughts !heading
4 |
5 | When you bundle your code, you usually introduce code from other third parties. Therefore, it may create implicit code repetition. Tree shaking eliminates unnecessary code; however, it is done at "compile" time. This means it can not detect what has been repeated (Even though Tree shaking technics seem to go beyond simple dead code elimination).
6 |
7 | Also, most IDEs detect the use of dead code, which IMO also mitigate tree shaking greatness.
8 |
9 | For instance, let's say you use two libraries.
10 | Lib1.js and Lib2.js.
11 | > Lib1 uses lodash and has been minified into lib1.min.js
12 | > Lib2 also uses lodash and has been minified into lib2.min.js.
13 |
14 | When you bundle your code containing lib1.js and lib2.js, you add lodash two times (or some functions of it).
15 |
16 | IMO, there are considerable advantages to not using bundled code.
17 |
18 | > - 1- Letting the browser cache all shared libraries is one of them; therefore, having the best caching system
19 | > (Chrome or Firefox would surely know the best way to cache files coming from a common ground).
20 | >
21 | >
22 | > - 2- Avoiding automated code repetition
23 | >
24 | >
25 | > - 3- Less painful and lengthy wait when the codebase becomes enormous.
26 | >
27 | >
28 | > - 4- Make Hot Reloading obsolete. Instead, use Cold Reloading (you reload when you save, when not the bundler has
29 | finished its compilation).
30 | >
31 | >
32 | > - 5- Working directly on the "original code" rather than a defigured one (even using source maps sometimes may make
33 | the experience not fantastic).
34 | >
35 | >
36 |
37 | ### In any case, ideally, **you would only bundle your code during production.**
38 |
39 |
40 |
--------------------------------------------------------------------------------
/docs/ideas/working-with-both-CJS-and-ESM.md:
--------------------------------------------------------------------------------
1 | 💡
2 |
3 | ## Working with both CJS and ESM !heading
4 |
5 | You may want to work with both CommonJs and ESM together. So, you benefit from both worlds.
6 |
7 | The CommonJs approach is a dynamic one. So, for example, you can do things like:
8 |
9 | ```javascript
10 | if (a)
11 | {
12 | // load module a
13 | require(a);
14 | }
15 | else
16 | {
17 | // load module b
18 | require(b)
19 | }
20 | ```
21 |
22 | With ESM and its static approach, loading both modules is necessary.
23 | ```javascript
24 | // load module a
25 | import "a";
26 | // load module b
27 | import "b";
28 | ```
29 |
30 |
31 |
--------------------------------------------------------------------------------
/docs/images/convert-to-esm-1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/docs/images/convert-to-esm-1.gif
--------------------------------------------------------------------------------
/docs/images/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/docs/images/img.png
--------------------------------------------------------------------------------
/docs/images/img_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/docs/images/img_1.png
--------------------------------------------------------------------------------
/docs/images/img_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/docs/images/img_2.png
--------------------------------------------------------------------------------
/docs/images/img_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/docs/images/img_3.png
--------------------------------------------------------------------------------
/docs/options/via-cli.md:
--------------------------------------------------------------------------------
1 | 🪛
2 |
3 | ## Options (via command line) !heading
4 |
5 |
6 | | **Options** | **Description** | **Expect** |
7 | |----------------|---------------------------------------------------------|--------------------------|
8 | | filepath | _File or pattern to convert_ | **Only required option** |
9 | | --output | _Output directory_ | directory path |
10 | | --html | _html files to receive importmaps_ | glob |
11 | | --noHeader | _Options to not generate automatic header_ | |
12 | | --keepExisting | _Options to skip already converted files_ | |
13 | | --target | _Setting the targeted environment_ | all / esm / browser |
14 | | --bundle | _Generate minified bundle for browser environment_ | file path |
15 | | --entrypoint | _Path to .js entrypoint_ | file path |
16 | | --update-all | _Automatically update package.json to set entry points_ | |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/eslint-runtime.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "rules": {
3 | "one-var": ["error", "never"]
4 | }
5 | };
6 |
--------------------------------------------------------------------------------
/example/.toesm.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | replaceStart : [
3 | {
4 | search : /const\s+ttt\s*=\s*require\(.mama-magnimus.\);/g,
5 | replace: "// ***"
6 | }
7 | ],
8 | replaceEnd : [
9 | {
10 | search : `// ***`,
11 | replace: "// --------- mama-magnimus was replaced ----------------"
12 | }
13 | ],
14 | replaceModules:
15 | {
16 | "rgb-hex": {
17 | cjs: {
18 | name : "rgb-hex-cjs",
19 | version: "@^3.0.0"
20 | },
21 | esm: {
22 | version: "@latest"
23 | }
24 | }
25 | },
26 | html :
27 | {
28 | importmap : {
29 | "ttt": "http://somewhere"
30 | },
31 | importmapReplace: [{
32 | search : "./node_modules",
33 | replace: `/node_modules`,
34 | regex: false
35 | }],
36 | }
37 |
38 | }
--------------------------------------------------------------------------------
/example/cjs/another.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/cjs/constants/constants.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | const SPECIAL_CONSTANTS = {
4 | WELCOME_CONTENT: "Welcome",
5 | };
6 |
7 | const SPECIAL_CONSTANTS_2 = {
8 | COMMAND_NOT_SENT : "COMMAND_NOT_SENT",
9 | };
10 |
11 | module.exports = {SPECIAL_CONSTANTS, SPECIAL_CONSTANTS_2};
--------------------------------------------------------------------------------
/example/cjs/constants/constants.json:
--------------------------------------------------------------------------------
1 | {
2 | "SOMETHING": "here"
3 | }
--------------------------------------------------------------------------------
/example/cjs/contexts-def.cjs:
--------------------------------------------------------------------------------
1 | const constants = {
2 | LOG_CONTEXT: {STANDARD: {}, TEST: {color: "red"}, C1: null, C2: null, C3: null, DEFAULT: {}},
3 | LOG_TARGETS: {DEV: {}, USER: {user: true}}
4 | }
5 |
6 | module.exports.LOG_CONTEXT = constants.LOG_CONTEXT
7 | module.exports.LOG_TARGETS = constants.LOG_TARGETS
--------------------------------------------------------------------------------
/example/cjs/demo-directives.cjs:
--------------------------------------------------------------------------------
1 | /** to-esm-browser: remove **/
2 | const path = require("path");
3 | const fs = require("fs");
4 | const os = require("os");
5 | /** to-esm-browser: end-remove **/
6 |
7 | const stuff = require("./demo-test-15.cjs");
8 |
9 | console.log(stuff.example.start())
10 |
11 | /** to-esm-all: skip **/
12 | console.log("Skip this 1");
13 | /** to-esm-all: end-skip **/
14 |
15 | const EOL =`
16 | `;
17 |
18 | /** to-esm-all: skip **/
19 | console.log("Skip this 2");
20 | /** to-esm-all: end-skip **/
21 |
22 |
23 | class Example2
24 | {
25 | constructor()
26 | {
27 | console.log("Hello you!");
28 | }
29 | }
30 |
31 | module.exports = new Example2();
32 | module.exports.example2 = new Example2();
33 |
--------------------------------------------------------------------------------
/example/cjs/demo-test-15.cjs:
--------------------------------------------------------------------------------
1 | const EOL =`
2 | `;
3 |
4 | /** to-esm-all: skip **/
5 | console.log("Skip this 3");
6 | /** to-esm-all: end-skip **/
7 |
8 |
9 | class Example
10 | {
11 | constructor()
12 | {
13 | console.log("Hello you!");
14 | }
15 |
16 | start()
17 | {
18 | console.log("I'm ready")
19 | }
20 | }
21 |
22 | module.exports = new Example();
23 | module.exports.example = new Example();
24 |
--------------------------------------------------------------------------------
/example/cjs/dep-1.cjs:
--------------------------------------------------------------------------------
1 | const SPECIFICS = {
2 | DIRECTION: {
3 | UP : "UP",
4 | DOWN: "DOWN"
5 | }
6 | };
7 |
8 | module.exports.DIRECTION = SPECIFICS.DIRECTION;
9 | module.exports.MESSAGE = SPECIFICS.MESSAGE;
10 | module.exports.SYSTEM_TYPE = SPECIFICS.SYSTEM_TYPE;
11 | module.exports = SPECIFICS;
12 |
13 |
--------------------------------------------------------------------------------
/example/cjs/dep-2.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "EXAMPLE": {
3 | "UP": "UP",
4 | "DOWN": "DOWN"
5 | }
6 | }
--------------------------------------------------------------------------------
/example/cjs/dep-3.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "EXAMPLE": {
3 | "UP": "UP",
4 | "DOWN": "DOWN"
5 | }
6 | }
--------------------------------------------------------------------------------
/example/cjs/input-less.js:
--------------------------------------------------------------------------------
1 | /** const chalk001 = require("chalk-cjs"); **/
2 | const chalk000 = require("chalk-cjs"); // const path = require("path");
3 | // const chalk002 = require("chalk-cjs");
4 | const aa = "const chalk003 = require(\"chalk-cjs\");"
5 | const colorConvert = require("color-convert-cjs");
6 | const magnimus = require("mama-magnimus");
7 | const magnimus = require("mama-magnimus-cjs");
8 | const rgbhex = /** Cool **/ require("rgb-hex-cjs");
9 | const INFO1 = require("./dep-1.cjs");
10 | const INFO2 = require("./dep-2.cjs");
11 | const INFO3 = require('./dep-3.js');
12 | const bb = `
13 | const chalk004 = require("chalk-cjs");
14 |
15 | const chalk005 = require("chalk-cjs");
16 | `
17 | const INFO4 = require("./something.js");
18 | const INFO5 = require("./something.cjs");
19 | const path = require("path");
20 |
21 | /**
22 | * Multi line comment
23 | */
24 | const {DIRECTION, MESSAGE} = require("./dep-1");
25 |
26 | // ----
27 |
28 | /**
29 | * @class SomeClass
30 | */
31 | class SomeClass
32 | {
33 | constructor()
34 | {
35 | console.log(DIRECTION)
36 | console.log(MESSAGE)
37 | console.log(INFO1)
38 | }
39 | }
40 |
41 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
42 | const chalk = require("chalk-cjs");
43 |
44 | module.exports = SomeClass;
--------------------------------------------------------------------------------
/example/cjs/more/again.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/cjs/more/dep-1.cjs:
--------------------------------------------------------------------------------
1 | const SPECIFICS = {
2 | DIRECTION: {
3 | UP : "UP",
4 | DOWN: "DOWN"
5 | }
6 | };
7 |
8 | module.exports.DIRECTION = SPECIFICS.DIRECTION;
9 | module.exports.MESSAGE = SPECIFICS.MESSAGE;
10 | module.exports.SYSTEM_TYPE = SPECIFICS.SYSTEM_TYPE;
11 | module.exports = SPECIFICS;
12 |
13 |
--------------------------------------------------------------------------------
/example/cjs/more/dep-5.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "EXAMPLE": {
3 | "UP": "UP",
4 | "DOWN": "DOWN"
5 | }
6 | }
--------------------------------------------------------------------------------
/example/cjs/more/dep-6.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "EXAMPLE": {
3 | "UP": "UP",
4 | "DOWN": "DOWN"
5 | }
6 | }
--------------------------------------------------------------------------------
/example/cjs/more/input-more.js:
--------------------------------------------------------------------------------
1 | const INFO1 = require("./dep-1.cjs");
2 | const INFO2 = require("./dep-5.js");
3 | const INFO3 = require("./dep-6.js");
4 | const INFO4 = require("./somehing.js");
5 | const INFO5 = require("./somehing.cjs");
6 |
7 | const {DIRECTION, MESSAGE} = require("./dep-1");
8 |
9 | // ----
10 |
11 | /**
12 | * @class SomeClass
13 | */
14 | class SomeClass
15 | {
16 | constructor()
17 | {
18 | console.log(DIRECTION)
19 | console.log(MESSAGE)
20 | console.log(INFO1)
21 | }
22 | }
23 |
24 | module.exports = SomeClass;
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
10 |
18 |
19 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/example/other.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [2022] [Patrice Thimothee]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/markdown.json:
--------------------------------------------------------------------------------
1 | {
2 | "build": "./README.md",
3 | "files": ["./docs/README.md"],
4 | "tableOfContents": {
5 | "heading": "# Table of contents",
6 | "lead": "number"
7 | }
8 | }
--------------------------------------------------------------------------------
/src/regexes/to-esm-add.txt:
--------------------------------------------------------------------------------
1 | \/\*\*\s*to-esm-(?:######)\s*:\s*add\s*([\s\S]*?)\*\*\/
--------------------------------------------------------------------------------
/src/regexes/to-esm-remove.txt:
--------------------------------------------------------------------------------
1 | \/\*\*\s*to-esm-(######)\s*:\s*remove\s*\*\*\/[\s\S]*?\/\*\*\s*to-esm-\1\s*:\s*end-remove\s*\*\*\/
--------------------------------------------------------------------------------
/src/regexes/to-esm-skip.txt:
--------------------------------------------------------------------------------
1 | \/\*\*\s*to-esm-(######})\s*:\s*skip\s*\*\*\/([\s\S]*?)\/\*\*\s*to-esm-\1\s*:\s*end-skip\s*\*\*\/
--------------------------------------------------------------------------------
/test/__test__.md:
--------------------------------------------------------------------------------
1 | ### This file is an indicator
--------------------------------------------------------------------------------
/test/assets/expect/case-1/imported/define-property/index.mjs:
--------------------------------------------------------------------------------
1 | import isDescriptor from "../../imported/is-descriptor/index.mjs";
2 | /*!
3 | * define-property
4 | *
5 | * Copyright (c) 2015, 2017, Jon Schlinkert.
6 | * Released under the MIT License.
7 | */
8 |
9 | 'use strict';
10 |
11 |
12 |
13 | export default function defineProperty(obj, prop, val) {
14 | if (typeof obj !== 'object' && typeof obj !== 'function') {
15 | throw new TypeError('expected an object or function.');
16 | }
17 |
18 | if (typeof prop !== 'string') {
19 | throw new TypeError('expected `prop` to be a string.');
20 | }
21 |
22 | if (isDescriptor(val) && ('set' in val || 'get' in val)) {
23 | return Object.defineProperty(obj, prop, val);
24 | }
25 |
26 | return Object.defineProperty(obj, prop, {
27 | configurable: true,
28 | enumerable: false,
29 | writable: true,
30 | value: val
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/test/assets/expect/case-1/imported/is-data-descriptor/index.mjs:
--------------------------------------------------------------------------------
1 | import typeOf from "../../imported/kind-of/index.mjs";
2 | /*!
3 | * is-data-descriptor
4 | *
5 | * Copyright (c) 2015-2017, Jon Schlinkert.
6 | * Released under the MIT License.
7 | */
8 |
9 | 'use strict';
10 |
11 |
12 |
13 | export default function isDataDescriptor(obj, prop) {
14 | // data descriptor properties
15 | var data = {
16 | configurable: 'boolean',
17 | enumerable: 'boolean',
18 | writable: 'boolean'
19 | };
20 |
21 | if (typeOf(obj) !== 'object') {
22 | return false;
23 | }
24 |
25 | if (typeof prop === 'string') {
26 | var val = Object.getOwnPropertyDescriptor(obj, prop);
27 | return typeof val !== 'undefined';
28 | }
29 |
30 | if (!('value' in obj) && !('writable' in obj)) {
31 | return false;
32 | }
33 |
34 | for (var key in obj) {
35 | if (key === 'value') continue;
36 |
37 | if (!data.hasOwnProperty(key)) {
38 | continue;
39 | }
40 |
41 | if (typeOf(obj[key]) === data[key]) {
42 | continue;
43 | }
44 |
45 | if (typeof obj[key] !== 'undefined') {
46 | return false;
47 | }
48 | }
49 | return true;
50 | };
51 |
--------------------------------------------------------------------------------
/test/assets/expect/case-1/imported/is-descriptor/index.mjs:
--------------------------------------------------------------------------------
1 | import typeOf from "../../imported/kind-of/index.mjs";
2 | import isAccessor from "../../imported/is-accessor-descriptor/index.mjs";
3 | import isData from "../../imported/is-data-descriptor/index.mjs";
4 | /*!
5 | * is-descriptor
6 | *
7 | * Copyright (c) 2015-2017, Jon Schlinkert.
8 | * Released under the MIT License.
9 | */
10 |
11 | 'use strict';
12 |
13 |
14 |
15 |
16 |
17 | export default function isDescriptor(obj, key) {
18 | if (typeOf(obj) !== 'object') {
19 | return false;
20 | }
21 | if ('get' in obj) {
22 | return isAccessor(obj, key);
23 | }
24 | return isData(obj, key);
25 | };
26 |
--------------------------------------------------------------------------------
/test/assets/expect/case-1/imported/is-number/index.mjs:
--------------------------------------------------------------------------------
1 | import typeOf from "../../imported/kind-of/index.mjs";
2 | /*!
3 | * is-number
4 | *
5 | * Copyright (c) 2014-2015, Jon Schlinkert.
6 | * Licensed under the MIT License.
7 | */
8 |
9 | 'use strict';
10 |
11 |
12 |
13 | export default function isNumber(num) {
14 | var type = typeOf(num);
15 |
16 | if (type === 'string') {
17 | if (!num.trim()) return false;
18 | } else if (type !== 'number') {
19 | return false;
20 | }
21 |
22 | return (num - num + 1) >= 0;
23 | };
24 |
--------------------------------------------------------------------------------
/test/assets/expect/case-1/imported/window-size/index.mjs:
--------------------------------------------------------------------------------
1 | import define from "../../imported/define-property/index.mjs";
2 | import utils from "./utils.mjs";
3 | /*!
4 | * window-size
5 | *
6 | * Copyright (c) 2014-2017, Jon Schlinkert.
7 | * Released under the MIT License.
8 | */
9 |
10 | 'use strict';
11 |
12 |
13 |
14 |
15 | /**
16 | * Expose `windowSize`
17 | */
18 |
19 | export default utils.get();
20 |
21 | if (module.exports) {
22 | /**
23 | * Expose `windowSize.get` method
24 | */
25 |
26 | define(module.exports, 'get', utils.get);
27 |
28 | /**
29 | * Expose methods for unit tests
30 | */
31 |
32 | define(module.exports, 'env', utils.env);
33 | define(module.exports, 'tty', utils.tty);
34 | define(module.exports, 'tput', utils.tput);
35 | define(module.exports, 'win', utils.win);
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/test/assets/expect/case-1/models/example-1/more/contexts-def.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @type {{C3: null, TEST: {symbol: string, color: string}, STANDARD: {}, C1: null, DEFAULT: {}, C2: null}}
4 | */
5 | export const LOG_CONTEXTS = {
6 | STANDARD: {},
7 | TEST: {color: "#B18904", symbol: "⏰"},
8 | TEST2: {color: "rgb(127, 127, 127)", symbol: "⏰"},
9 | TEST3: {color: "blue", symbol: "⏰"},
10 | C1: null,
11 | C2: null,
12 | C3: null,
13 | INFO: {},
14 | DEFAULT: {}
15 | };
16 |
17 | export const LOG_TARGETS = {ALL: "ALL", DEV1: "TOM", DEV2: "TIM", DEV3: "ME", USER: "USER"};
--------------------------------------------------------------------------------
/test/assets/expect/case-1/src/constants.mjs:
--------------------------------------------------------------------------------
1 | const constants = {
2 | COLOR_TABLE: [
3 | "#d2466e", // Error context color
4 | "#FFA07A", // Default context color
5 | "#FF7F50",
6 | "#FF6347",
7 | "#FFE4B5",
8 | "#ADFF2F",
9 | "#808000",
10 | "#40E0D0",
11 | "#1E90FF",
12 | "#EE82EE",
13 | "#708090",
14 | "#DEB887",
15 | "#FE642E",
16 | "#210B61",
17 | "#088A4B",
18 | "#5E610B",
19 | "#FA8258",
20 | "#088A68",
21 | "#B40431",
22 | ],
23 | SYSTEM: {
24 | BROWSER: "BROWSER",
25 | NODE: "NODE"
26 | }
27 |
28 | };
29 |
30 | export const COLOR_TABLE = constants.COLOR_TABLE;
31 | export const SYSTEM = constants.SYSTEM;
32 | export const MAX_CHILDREN_DOM_ANALOGGER = 2000;
33 | export const CLASS_REMOVED_NOTIF = "analogger-removed-notif";
34 | export const CONSOLE_AREA_CLASSNAME = "analogger-view";
35 | export const LINE_CLASSNAME = "to-esm-line";
36 |
37 | export const ADD_TYPE = {
38 | TOP: "TOP",
39 | BOTTOM: "BOTTOM"
40 | };
41 |
42 | export const ANALOGGER_NAME = "ANALOGGER";
43 |
44 |
45 |
46 | export const PREDEFINED_FORMATS = {
47 | DEFAULT_FORMAT: "FORMAT1"
48 | };
49 |
--------------------------------------------------------------------------------
/test/assets/expect/case-2/models/example-1/more/contexts-def.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @type {{C3: null, TEST: {symbol: string, color: string}, STANDARD: {}, C1: null, DEFAULT: {}, C2: null}}
4 | */
5 | export const LOG_CONTEXTS = {
6 | STANDARD: {},
7 | TEST: {color: "#B18904", symbol: "⏰"},
8 | TEST2: {color: "rgb(127, 127, 127)", symbol: "⏰"},
9 | TEST3: {color: "blue", symbol: "⏰"},
10 | C1: null,
11 | C2: null,
12 | C3: null,
13 | INFO: {},
14 | DEFAULT: {}
15 | };
16 |
17 | export const LOG_TARGETS = {ALL: "ALL", DEV1: "TOM", DEV2: "TIM", DEV3: "ME", USER: "USER"};
--------------------------------------------------------------------------------
/test/assets/expect/case-2/node_modules/define-property/index.mjs:
--------------------------------------------------------------------------------
1 | import isDescriptor from "../is-descriptor/index.mjs";
2 | /*!
3 | * define-property
4 | *
5 | * Copyright (c) 2015, 2017, Jon Schlinkert.
6 | * Released under the MIT License.
7 | */
8 |
9 | 'use strict';
10 |
11 |
12 |
13 | export default function defineProperty(obj, prop, val) {
14 | if (typeof obj !== 'object' && typeof obj !== 'function') {
15 | throw new TypeError('expected an object or function.');
16 | }
17 |
18 | if (typeof prop !== 'string') {
19 | throw new TypeError('expected `prop` to be a string.');
20 | }
21 |
22 | if (isDescriptor(val) && ('set' in val || 'get' in val)) {
23 | return Object.defineProperty(obj, prop, val);
24 | }
25 |
26 | return Object.defineProperty(obj, prop, {
27 | configurable: true,
28 | enumerable: false,
29 | writable: true,
30 | value: val
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/test/assets/expect/case-2/node_modules/is-data-descriptor/index.mjs:
--------------------------------------------------------------------------------
1 | import typeOf from "../kind-of/index.mjs";
2 | /*!
3 | * is-data-descriptor
4 | *
5 | * Copyright (c) 2015-2017, Jon Schlinkert.
6 | * Released under the MIT License.
7 | */
8 |
9 | 'use strict';
10 |
11 |
12 |
13 | export default function isDataDescriptor(obj, prop) {
14 | // data descriptor properties
15 | var data = {
16 | configurable: 'boolean',
17 | enumerable: 'boolean',
18 | writable: 'boolean'
19 | };
20 |
21 | if (typeOf(obj) !== 'object') {
22 | return false;
23 | }
24 |
25 | if (typeof prop === 'string') {
26 | var val = Object.getOwnPropertyDescriptor(obj, prop);
27 | return typeof val !== 'undefined';
28 | }
29 |
30 | if (!('value' in obj) && !('writable' in obj)) {
31 | return false;
32 | }
33 |
34 | for (var key in obj) {
35 | if (key === 'value') continue;
36 |
37 | if (!data.hasOwnProperty(key)) {
38 | continue;
39 | }
40 |
41 | if (typeOf(obj[key]) === data[key]) {
42 | continue;
43 | }
44 |
45 | if (typeof obj[key] !== 'undefined') {
46 | return false;
47 | }
48 | }
49 | return true;
50 | };
51 |
--------------------------------------------------------------------------------
/test/assets/expect/case-2/node_modules/is-descriptor/index.mjs:
--------------------------------------------------------------------------------
1 | import typeOf from "../kind-of/index.mjs";
2 | import isAccessor from "../is-accessor-descriptor/index.mjs";
3 | import isData from "../is-data-descriptor/index.mjs";
4 | /*!
5 | * is-descriptor
6 | *
7 | * Copyright (c) 2015-2017, Jon Schlinkert.
8 | * Released under the MIT License.
9 | */
10 |
11 | 'use strict';
12 |
13 |
14 |
15 |
16 |
17 | export default function isDescriptor(obj, key) {
18 | if (typeOf(obj) !== 'object') {
19 | return false;
20 | }
21 | if ('get' in obj) {
22 | return isAccessor(obj, key);
23 | }
24 | return isData(obj, key);
25 | };
26 |
--------------------------------------------------------------------------------
/test/assets/expect/case-2/node_modules/is-number/index.mjs:
--------------------------------------------------------------------------------
1 | import typeOf from "../kind-of/index.mjs";
2 | /*!
3 | * is-number
4 | *
5 | * Copyright (c) 2014-2015, Jon Schlinkert.
6 | * Licensed under the MIT License.
7 | */
8 |
9 | 'use strict';
10 |
11 |
12 |
13 | export default function isNumber(num) {
14 | var type = typeOf(num);
15 |
16 | if (type === 'string') {
17 | if (!num.trim()) return false;
18 | } else if (type !== 'number') {
19 | return false;
20 | }
21 |
22 | return (num - num + 1) >= 0;
23 | };
24 |
--------------------------------------------------------------------------------
/test/assets/expect/case-2/node_modules/window-size/index.mjs:
--------------------------------------------------------------------------------
1 | import define from "../define-property/index.mjs";
2 | import utils from "./utils.mjs";
3 | /*!
4 | * window-size
5 | *
6 | * Copyright (c) 2014-2017, Jon Schlinkert.
7 | * Released under the MIT License.
8 | */
9 |
10 | 'use strict';
11 |
12 |
13 |
14 |
15 | /**
16 | * Expose `windowSize`
17 | */
18 |
19 | export default utils.get();
20 |
21 | if (module.exports) {
22 | /**
23 | * Expose `windowSize.get` method
24 | */
25 |
26 | define(module.exports, 'get', utils.get);
27 |
28 | /**
29 | * Expose methods for unit tests
30 | */
31 |
32 | define(module.exports, 'env', utils.env);
33 | define(module.exports, 'tty', utils.tty);
34 | define(module.exports, 'tput', utils.tput);
35 | define(module.exports, 'win', utils.win);
36 | }
37 |
38 |
--------------------------------------------------------------------------------
/test/assets/expect/case-2/src/constants.mjs:
--------------------------------------------------------------------------------
1 | const constants = {
2 | COLOR_TABLE: [
3 | "#d2466e", // Error context color
4 | "#FFA07A", // Default context color
5 | "#FF7F50",
6 | "#FF6347",
7 | "#FFE4B5",
8 | "#ADFF2F",
9 | "#808000",
10 | "#40E0D0",
11 | "#1E90FF",
12 | "#EE82EE",
13 | "#708090",
14 | "#DEB887",
15 | "#FE642E",
16 | "#210B61",
17 | "#088A4B",
18 | "#5E610B",
19 | "#FA8258",
20 | "#088A68",
21 | "#B40431",
22 | ],
23 | SYSTEM: {
24 | BROWSER: "BROWSER",
25 | NODE: "NODE"
26 | }
27 |
28 | };
29 |
30 | export const COLOR_TABLE = constants.COLOR_TABLE;
31 | export const SYSTEM = constants.SYSTEM;
32 | export const MAX_CHILDREN_DOM_ANALOGGER = 2000;
33 | export const CLASS_REMOVED_NOTIF = "analogger-removed-notif";
34 | export const CONSOLE_AREA_CLASSNAME = "analogger-view";
35 | export const LINE_CLASSNAME = "to-esm-line";
36 |
37 | export const ADD_TYPE = {
38 | TOP: "TOP",
39 | BOTTOM: "BOTTOM"
40 | };
41 |
42 | export const ANALOGGER_NAME = "ANALOGGER";
43 |
44 |
45 |
46 | export const PREDEFINED_FORMATS = {
47 | DEFAULT_FORMAT: "FORMAT1"
48 | };
49 |
--------------------------------------------------------------------------------
/test/assets/expect/case-3/common/data-exchanger.mjs:
--------------------------------------------------------------------------------
1 | export default {
2 | "EVENT_MESSAGE_FROM_PRELOAD_TO_RENDERER": "A003_EVENT_MESSAGE_FROM_PRELOAD_TO_RENDERER",
3 | "RESPONSE_MESSAGE_FROM_RENDERER_TO_PRELOAD": "A004_RESPONSE_MESSAGE_FROM_RENDERER_TO_PRELOAD",
4 |
5 | "RESPONSE_MESSAGE_FROM_PRELOAD_TO_RENDERER": "A006_RESPONSE_MESSAGE_FROM_PRELOAD_TO_RENDERER",
6 |
7 | "MAIN_CHANNEL_DATA": "A007_MYEVENT",
8 | "CONSOLE_ESM": "color: #A5AF8A",
9 | "CONSOLE_CJS": "color: #F5A65A",
10 | "CONSOLE_SUCCESS": "color: yellow",
11 |
12 | "CHANNEL_MESSAGE_PREFIX": "data-message-",
13 | "CHANNEL_RESPONSE_PREFIX": "data-response-",
14 |
15 | "EXCHANGE_DIV_ID_UP": "UP-434-AssGK2154G2RE-4554",
16 | "EXCHANGE_DIV_ID_DOWN": "DOWN-434-AssGK2154G2RE-4554",
17 |
18 | "PREFIX_MESSAGE": "message-",
19 | "PREFIX_RESPONSE": "response-",
20 |
21 | "SUFFIX_TEST": "___test___Request",
22 |
23 | "EXCHANGER_TYPE": {
24 | "UP": "UP",
25 | "DOWN": "DOWN"
26 | }
27 | }
--------------------------------------------------------------------------------
/test/assets/expect/case-3/common/specificities.mjs:
--------------------------------------------------------------------------------
1 | const SPECIFICS = {
2 | DIRECTION: {
3 | UP : "UP", // UP: Renderer => Preloader => Main Process
4 | DOWN: "DOWN" // DOWN: Main Process => Preloader => Renderer
5 | },
6 | MESSAGE_TYPE: {
7 | MESSAGE: "MESSAGE",
8 | RESPONSE: "RESPONSE"
9 | },
10 | SYSTEM_TYPE: {
11 | PRELOADER: "PRELOADER",
12 | RENDERER: " RENDERER", // The extra space is for the console alignment. Can be removed safely in case of problem.
13 | MAIN: "MAIN",
14 | UNKNOWN: "UNKNOWN"
15 | }
16 |
17 | };
18 |
19 | export const DIRECTION = SPECIFICS.DIRECTION;
20 | export const MESSAGE_TYPE = SPECIFICS.MESSAGE_TYPE;
21 | export const SYSTEM_TYPE = SPECIFICS.SYSTEM_TYPE;
22 | export default SPECIFICS;
23 |
24 |
--------------------------------------------------------------------------------
/test/assets/expect/case-3/demo-test-34.mjs:
--------------------------------------------------------------------------------
1 | import commonDir from "./node_modules/commondir/index.mjs";
2 | import toAnsi from "./node_modules/to-ansi/index.mjs";
3 | import CommonFeatureExchanger from "./common/common-feature-exchanger.mjs";
4 | import DATA_EXCHANGE_INFO from "./common/data-exchanger.mjs";
5 | // Load a library only CJS compatible
6 |
7 |
8 | // Load hybrid library
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/assets/expect/case-3/node_modules/commondir/index.mjs:
--------------------------------------------------------------------------------
1 | import path from "path";
2 |
3 | export default function (basedir, relfiles) {
4 | if (relfiles) {
5 | var files = relfiles.map(function (r) {
6 | return path.resolve(basedir, r);
7 | });
8 | }
9 | else {
10 | var files = basedir;
11 | }
12 |
13 | var res = files.slice(1).reduce(function (ps, file) {
14 | if (!file.match(/^([A-Za-z]:)?\/|\\/)) {
15 | throw new Error('relative path without a basedir');
16 | }
17 |
18 | var xs = file.split(/\/+|\\+/);
19 | for (
20 | var i = 0;
21 | ps[i] === xs[i] && i < Math.min(ps.length, xs.length);
22 | i++
23 | );
24 | return ps.slice(0, i);
25 | }, files[0].split(/\/+|\\+/));
26 |
27 | // Windows correctly handles paths with forward-slashes
28 | return res.length > 1 ? res.join('/') : '/'
29 | };
30 |
--------------------------------------------------------------------------------
/test/assets/expect/case-4/_root/projects/to-esm/test/assets/given/my-test-class.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [/projects/to-esm/test/assets/given/my-test-class.cjs]{@link /projects/to-esm/test/assets/given/my-test-class.cjs}
5 | *
6 | **/
7 |
8 | class MyTestClass
9 | {
10 | constructor()
11 | {
12 |
13 | }
14 |
15 | someMethod()
16 | {
17 | console.log(`Some method was called`)
18 | }
19 | }
20 |
21 | export default MyTestClass;
--------------------------------------------------------------------------------
/test/assets/expect/case-4/demo-test-43.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-43.cjs]{@link ./assets/given/demo-test-43.cjs}
5 | *
6 | **/
7 | import MyClass from "./_root/projects/to-esm/test/assets/given/my-test-class.mjs";
8 |
9 | const instance = new MyClass();
10 | instance.someMethod();
11 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-bad-syntax.mjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | var QuickLog4 = "rr";
7 |
8 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
9 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
10 |
11 | QuickLog4 = require("../../src/cjs/quick-log.cjs")
12 |
13 | let myLog1, QuickLog5, yourLog;
14 | let myLog2, QuickLog6, yourLog2;
15 | let QuickLog7, myLog2, yourLog2;
16 |
17 | QuickLog.setContexts(LOG_CONTEXT);
18 | QuickLog.setTargets(LOG_TARGETS);
19 |
20 | QuickLog5 = require("../../src/cjs/quick-log.cjs");
21 | QuickLog6 = require("../../src/cjs/quick-log.cjs")
22 | QuickLog7 = require("../../src/cjs/quick-log.cjs")
23 |
24 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
25 |
26 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
27 |
28 |
29 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
30 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
31 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
32 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
33 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
34 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
35 | QuickLog.log(`Basic Log example 1`);
36 | QuickLog2.log(`Basic Log example 1`);
37 | QuickLog3.log(`Basic Log example 1`);
38 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-10.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-10.cjs]{@link ./assets/given/demo-test-10.cjs}
5 | *
6 | **/
7 | import rgbhex from "./node_modules/rgb-hex/index.mjs";
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-11.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * [./test/assets/given/demo-test-10.cjs]{@link ./test/assets/given/demo-test-10.cjs}
5 | *
6 | **/
7 | import rgbhex from "./node_modules/rgb-hex/index.mjs";;
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-12.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-12.cjs]{@link ./assets/given/demo-test-12.cjs}
5 | *
6 | **/
7 |
8 |
9 | abc
10 | const path = require("path1");
11 | def
12 |
13 | import rgbHex from "./node_modules/rgb-hex-cjs/index.mjs";
14 | import {COLOR_TABLE, SYSTEM} from "./constants.mjs";
15 |
16 | const EOL =`
17 | `;
18 |
19 | ghi
20 | import path from "path2";
21 | jkl
22 |
23 | mno
24 | const path = require("path3");
25 | pqr
26 |
27 |
28 | class Example
29 | {
30 |
31 | }
32 |
33 |
34 | console.log("1- LogToFile is not supported in this environment. ")
35 |
36 |
37 | console.log("2- LogToFile is not supported in this environment. ")
38 |
39 |
40 |
41 |
42 | export default new Example();
43 | export const anaLogger = new Example();
44 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-13-bis.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-13-bis.cjs]{@link ./assets/given/demo-test-13-bis.cjs}
5 | *
6 | **/
7 |
8 |
9 |
10 | import os from "os";
11 |
12 |
13 | abc
14 | console.log("Skip this 1");
15 | def
16 |
17 | import rgbHex from "./node_modules/rgb-hex-cjs/index.mjs";
18 | import {COLOR_TABLE, SYSTEM} from "./constants.mjs";
19 |
20 | console.log("1- LogToFile is not supported in this environment. ")
21 |
22 |
23 |
24 |
25 | console.log("3- LogToFile is not supported in this environment. ")
26 |
27 |
28 | const EOL =`
29 | `;
30 |
31 | ghi
32 | console.log("Skip this 2");
33 | jkl
34 |
35 |
36 | class Example
37 | {
38 |
39 | }
40 |
41 | export default new Example();
42 | export const anaLogger = new Example();
43 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-13.mjs:
--------------------------------------------------------------------------------
1 |
2 |
3 | abc
4 | console.log("Skip this 1");
5 | def
6 |
7 | import rgbHex from "./node_modules/rgb-hex-cjs/index.mjs";
8 | import {COLOR_TABLE, SYSTEM} from "./constants.mjs";
9 |
10 | console.log("1- LogToFile is not supported in this environment. ")
11 |
12 |
13 | console.log("2- LogToFile is not supported in this environment. ")
14 |
15 |
16 | console.log("3- LogToFile is not supported in this environment. ")
17 |
18 |
19 | const EOL =`
20 | `;
21 |
22 | ghi
23 | console.log("Skip this 2");
24 | jkl
25 |
26 |
27 | class Example
28 | {
29 |
30 | }
31 |
32 | export default new Example();
33 | export const anaLogger = new Example();
34 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-14.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * [./given/demo-test-14.cjs]{@link ./given/demo-test-14.cjs}
5 | *
6 | **/
7 | import stuff from "./given/demo-test-15.mjs";
8 |
9 |
10 | console.log(stuff.example.start())
11 |
12 | /** to-esm-all: skip **/
13 | console.log("Skip this 1");
14 | /** to-esm-all: end-skip **/
15 |
16 | const EOL =`
17 | `;
18 |
19 | /** to-esm-all: skip **/
20 | console.log("Skip this 2");
21 | /** to-esm-all: end-skip **/
22 |
23 |
24 | class Example2
25 | {
26 | constructor()
27 | {
28 | console.log("Hello you!");
29 | }
30 | }
31 |
32 | export default new Example2();
33 | export const example2 = new Example2();
34 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-19.mjs:
--------------------------------------------------------------------------------
1 | /** code example extracted from a Node module **/
2 | 'use strict';
3 |
4 | // Export FSWatcher class
5 | export const FSWatcher = FSWatcher;
6 |
7 | /**
8 | * Instantiates watcher with paths to be tracked.
9 | * @param {String|Array} paths file/directory paths and/or globs
10 | * @param {Object=} options chokidar opts
11 | * @returns an instance of FSWatcher for chaining.
12 | */
13 | export const watch = (paths, options) => {
14 | const watcher = new FSWatcher(options);
15 | watcher.add(paths);
16 | return watcher;
17 | };
18 |
19 |
20 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-20.mjs:
--------------------------------------------------------------------------------
1 | import db from "mime-db";
2 | import _toesmTemp1 from "path";
3 | /** This file is an extract of a module. Use for testing only **/
4 | 'use strict'
5 |
6 | /**
7 | * Module dependencies.
8 | * @private
9 | */
10 |
11 |
12 |
13 | var extname = _toesmTemp1.extname
14 |
15 |
16 | /**
17 | * Module variables.
18 | * @private
19 | */
20 |
21 | var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
22 | var TEXT_TYPE_REGEXP = /^text\//i
23 |
24 | /**
25 | * Module exports.
26 | * @public
27 | */
28 |
29 | export function charset (type) {
30 | }
31 |
32 | /**
33 | * Create a full Content-Type header given a MIME type or extension.
34 | *
35 | * @param {string} str
36 | * @return {boolean|string}
37 | */
38 |
39 | function contentType (str) {
40 | }
41 |
42 | function extension (type) {
43 | if (!type || typeof type !== 'string') {
44 | return false
45 | }
46 | }
47 |
48 | function lookup (path) {
49 | if (!path || typeof path !== 'string') {
50 | return false
51 | }
52 |
53 | // get the extension ("ext" or ".ext" or full path)
54 | var extension = extname('x.' + path)
55 | .toLowerCase()
56 | .substr(1)
57 |
58 | if (!extension) {
59 | return false
60 | }
61 |
62 | return exports.types[extension] || false
63 | }
64 |
65 | /**
66 | * Populate the extensions and types maps.
67 | * @private
68 | */
69 | function populateMaps (extensions, types) {
70 | // source preference (least -> most)
71 | }
72 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-22.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-22.cjs]{@link ./assets/given/demo-test-22.cjs}
5 | *
6 | **/
7 | import { fileURLToPath } from "url";
8 | import { dirname } from "path";
9 | const __dirname = dirname(fileURLToPath(import.meta.url));
10 | import { EMPTY_BUFFER } from "./constants.mjs";
11 | import _toesmTemp1 from "node-gyp-build";
12 | /**
13 | * Some code extract from module to use with test only
14 | */
15 | 'use strict';
16 |
17 |
18 | function concat(list, totalLength) {
19 | }
20 |
21 | /**
22 | * Some comment
23 | *
24 | */
25 | function _mask(source, mask, output, offset, length) {
26 | for (let i = 0; i < length; i++) {
27 | output[offset + i] = source[i] ^ mask[i & 3];
28 | }
29 | }
30 |
31 | function _unmask(buffer, mask) {
32 | for (let i = 0; i < buffer.length; i++) {
33 | buffer[i] ^= mask[i & 3];
34 | }
35 | }
36 |
37 | function toArrayBuffer(buf) {
38 | if (buf.byteLength === buf.buffer.byteLength) {
39 | return buf.buffer;
40 | }
41 |
42 | return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
43 | }
44 |
45 | /**
46 | * Converts `data` to a `Buffer`.
47 | *
48 | * @param {*} data The data to convert
49 | * @return {Buffer} The buffer
50 | * @throws {TypeError}
51 | * @public
52 | */
53 |
54 | function toBuffer(data) {
55 |
56 | return buf;
57 | }
58 |
59 | try {
60 | export default _toesmTemp1(__dirname);
61 |
62 | } catch (e) {
63 | export default require('./fallback');
64 | }
65 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-23.mjs:
--------------------------------------------------------------------------------
1 | import isValidUTF8 from "utf-8-validate";
2 | 'use strict';
3 |
4 | //
5 | // Allowed token characters:
6 | //
7 | // '!', '#', '$', '%', '&', ''', '*', '+', '-',
8 | // '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~'
9 | //
10 | // tokenChars[32] === 0 // ' '
11 | // tokenChars[33] === 1 // '!'
12 | // tokenChars[34] === 0 // '"'
13 | // ...
14 | //
15 | // prettier-ignore
16 |
17 |
18 | export default {
19 | isValidStatusCode,
20 | isValidUTF8(buf)
21 | {
22 | return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
23 | },
24 | tokenChars
25 | };
26 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-24.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * [./test/assets/given/demo-test-24.cjs]{@link ./test/assets/given/demo-test-24.cjs}
5 | *
6 | **/
7 | import path from "path";
8 | 'use strict';
9 |
10 |
11 | export const add = (a, b)=>
12 | {
13 | return a + b
14 | }
15 |
16 | export default {
17 | add
18 | };
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-27.mjs:
--------------------------------------------------------------------------------
1 | export default stringify
2 | export const getSerialize = serializer
3 |
4 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-29.min.mjs:
--------------------------------------------------------------------------------
1 | "use strict";var{parse:S,stringify:N}=JSON,{keys:d}=Object,y=String,O="string",x={},h="object",w=(t,s)=>s,j=t=>t instanceof y?y(t):t,k=(t,s)=>typeof s===O?new y(s):s,b=(t,s,n,e)=>{let r=[];for(let c=d(n),{length:l}=c,i=0;i{let e=y(s.push(n)-1);return t.set(n,e),e},G=(t,s)=>{let n=S(t,k).map(j),e=n[0],r=s||w,c=typeof e===h&&e?b(n,new Set,e,r):e;return r.call({"":c},"",c)},H=(t,s,n)=>{let e=s&&typeof s===h?(f,g)=>f===""||-1S(H(t)),J=t=>G(N(t)),M={aa:1,bb:2},T="Something",v="Anything",A=()=>{};"use strict";export{v as ANYTHING,T as SOMETHING,A as SOMETHING2,M as default,J as fromJSON,G as parse,H as stringify,I as toJSON};
2 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-3.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-3.cjs]{@link ./assets/given/demo-test-3.cjs}
5 | *
6 | **/
7 | import chalk000 from "chalk-cjs";
8 | import magnimus from "mama-magnimus";
9 | import magnimus2 from "mama-magnimus-cjs";
10 | import rgbhex from "./node_modules/rgb-hex-cjs/index.mjs";
11 | import INFO1 from "./dep-1.mjs";
12 | import INFO2 from "./dep-2.mjs";
13 | import INFO3 from './dep-3.mjs';
14 | import INFO4 from "./something.mjs";
15 | import INFO5 from "./something.mjs";
16 | import path from "path";
17 | import {DIRECTION, MESSAGE} from "./dep-1.mjs";
18 | /** const chalk001 = require("chalk-cjs"); **/
19 | // const path = require("path");
20 | // const chalk002 = require("chalk-cjs");
21 | const aa = "const chalk003 = require(\"chalk-cjs\");"
22 |
23 |
24 |
25 |
26 |
27 |
28 | const bb = `
29 | const chalk004 = require("chalk-cjs");
30 |
31 | const chalk005 = require("chalk-cjs");
32 | `
33 |
34 |
35 |
36 |
37 | /**
38 | * Multi line comment
39 | */
40 |
41 |
42 | // ----
43 |
44 | /**
45 | * @class SomeClass
46 | */
47 | class SomeClass
48 | {
49 | constructor()
50 | {
51 | console.log(DIRECTION)
52 | console.log(MESSAGE)
53 | console.log(INFO1)
54 | }
55 | }
56 |
57 | export default SomeClass;
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-31.mjs:
--------------------------------------------------------------------------------
1 |
2 |
3 | abc
4 | const path = require("path1");
5 | def
6 |
7 | import rgbHex from "./node_modules/rgb-hex-cjs/index.mjs";
8 | import {COLOR_TABLE, SYSTEM} from "./constants.mjs";
9 |
10 | const EOL =`
11 | `;
12 |
13 | ghi
14 | import path from "path2";
15 | jkl
16 |
17 | mno
18 | const path = require("path3");
19 | pqr
20 |
21 |
22 | class Example
23 | {
24 |
25 | }
26 |
27 |
28 | console.log("1- LogToFile is not supported in this environment. ")
29 |
30 |
31 | console.log("2- LogToFile is not supported in this environment. ")
32 |
33 |
34 |
35 |
36 | export default new Example();
37 | export const anaLogger = new Example();
38 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-33.mjs:
--------------------------------------------------------------------------------
1 | import commonDir from "./node_modules/commondir/index.mjs";
2 | import toAnsi from "to-ansi";
3 | import CommonFeatureExchanger from "./common/common-feature-exchanger.mjs";
4 | import DATA_EXCHANGE_INFO from "./common/data-exchanger.mjs";
5 | // Load a library only CJS compatible
6 |
7 |
8 | // Load hybrid library
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-34.mjs:
--------------------------------------------------------------------------------
1 | import commonDir from "./node_modules/commondir/index.mjs";
2 | import toAnsi from "./node_modules/to-ansi/index.mjs";
3 | import CommonFeatureExchanger from "./common/common-feature-exchanger.mjs";
4 | import DATA_EXCHANGE_INFO from "./common/data-exchanger.mjs";
5 | // Load a library only CJS compatible
6 |
7 |
8 | // Load hybrid library
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-36.mjs:
--------------------------------------------------------------------------------
1 | // const pingServer
2 | export const pingServer = function()
3 | {
4 | };
5 |
6 |
7 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-37.mjs:
--------------------------------------------------------------------------------
1 | export default something;
2 | export default something;
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-38.mjs:
--------------------------------------------------------------------------------
1 | // #!/usr/bin/env node
2 | /**
3 | * DO NOT EDIT THIS FILE DIRECTLY.
4 | * This file is generated following the conversion of
5 | * @see [./assets/given/demo-test-38.cjs]{@link ./assets/given/demo-test-38.cjs}
6 | *
7 | **/
8 | import {findPackageEntryPoint} from "./node_modules/to-ansi/index.mjs";
9 |
10 | const argv = minimist(process.argv.slice(2));
11 |
12 | const init = (argv) =>
13 | {
14 | const name = argv.name;
15 | const dirpath = argv.path;
16 | const target = argv.target;
17 |
18 | let isCjs = false, isModule = false, isBrowser = false;
19 | if (target === "browser")
20 | {
21 | isBrowser = true;
22 | }
23 | else if (target === "esm")
24 | {
25 | isModule = true;
26 | }
27 | else if (target === "cjs")
28 | {
29 | isCjs = true;
30 | }
31 |
32 | const entrypoint =
33 | findPackageEntryPoint(name, dirpath, {isCjs, isModule, isBrowser});
34 |
35 | if (!entrypoint)
36 | {
37 | console.log("No entrypoint detected on this module/path");
38 | return;
39 | }
40 |
41 | console.log(entrypoint);
42 | };
43 |
44 | init(argv);
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-4.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-4.cjs]{@link ./assets/given/demo-test-4.cjs}
5 | *
6 | **/
7 | /**
8 | */
9 | const SPECIAL_CONSTANTS = {
10 | WELCOME_CONTENT: "Welcome",
11 | };
12 |
13 | const SPECIAL_CONSTANTS_2 = {
14 | COMMAND_NOT_SENT : "COMMAND_NOT_SENT",
15 | };
16 |
17 | export default {SPECIAL_CONSTANTS, SPECIAL_CONSTANTS_2};
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-40.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-40.cjs]{@link ./assets/given/demo-test-40.cjs}
5 | *
6 | **/
7 | let _terminalSize = {};
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-41.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-41.cjs]{@link ./assets/given/demo-test-41.cjs}
5 | *
6 | **/
7 | import os from "os";
8 | let _terminalSize = {};
9 |
10 |
11 |
12 | let congrats = {}
13 |
14 |
15 |
16 | // Comment 1
17 | let say = "good morning";
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-42.mjs:
--------------------------------------------------------------------------------
1 | import os from "os";
2 | import toAnsi from "to-ansi";
3 | import {COLOR_TABLE, SYSTEM, MAX_CHILDREN_DOM_ANALOGGER, CLASS_REMOVED_NOTIF, ADD_TYPE, CONSOLE_AREA_CLASSNAME,
4 | PREDEFINED_FORMATS, ANALOGGER_NAME, LINE_CLASSNAME
5 | } from "./constants.mjs";
6 | import {stringify} from "flatted";
7 | let _terminalSize = {};
8 | let a1 = 1;
9 | let a2 = 2;
10 | // Comment 1
11 | let a3 = 3;
12 | // Comment 100
13 | console.log("Skip this 100");
14 | let a4 = 4;
15 | let a5 = 5;
16 | let a6 = 6;
17 | // Should be there (4)
18 | let _terminalSize2 = "--------------";
19 | let a7 = 7;
20 | let a8 = 8;
21 | const PREDEFINED_CONTEXT_NAMES = {
22 | "DEFAULT": "DEFAULT",
23 | // "LOG" : "LOG",
24 | // "INFO" : "INFO",
25 | // "WARN" : "WARN",
26 | // "ATTENTION": "ATTENTION",
27 | "ERROR": "ERROR"
28 | };
29 | const EOL = `
30 | `;
31 | class ____AnaLogger
32 | {
33 | }
34 | export const AnaLogger = ____AnaLogger;
35 | const _AnaLogger = AnaLogger;
36 | const __AnaLogger = ____AnaLogger;
37 | export default __AnaLogger;
38 | export const anaLogger = new ____AnaLogger();
39 | const ___anaLogger = anaLogger;
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-43.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-43.cjs]{@link ./assets/given/demo-test-43.cjs}
5 | *
6 | **/
7 | import MyClass from "./_root/projects/to-esm/test/assets/given/my-test-class.mjs";
8 |
9 | const instance = new MyClass();
10 | instance.someMethod();
11 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-44.mjs:
--------------------------------------------------------------------------------
1 |
2 | const escapeDollar = (text) =>
3 | {
4 | return text.split("$").join("$$");
5 | };
6 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-46.mjs:
--------------------------------------------------------------------------------
1 |
2 |
3 | import toAnsi from "../../../../node_modules/to-ansi/index.mjs";
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-52.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @param serverUrl
4 | * @param delay
5 | * @param {"firefox"|"google chrome"|""} browserName
6 | * @param args
7 | * @returns {Promise}
8 | */
9 | export async function openUrl (serverUrl, {delay = 1000, browserName = "", args = []} = {})
10 | {
11 | try
12 | {
13 | let options = {};
14 |
15 | if (browserName)
16 | {
17 | options.app = {name: browserName};
18 | }
19 |
20 | if (args && args.length)
21 | {
22 | options.arguments = args;
23 | }
24 |
25 | await open(serverUrl, options);
26 | await sleep(delay);
27 |
28 | return true;
29 | }
30 | catch (e)
31 | {
32 | console.error({lid: 3361}, e.message);
33 | }
34 |
35 | return false;
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-55.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const ff001 = function ()
6 | {
7 | try
8 | {
9 | return true;
10 | }
11 | catch (e)
12 | {
13 | console.error({lid: 1235}, e.message);
14 | }
15 | return false;
16 | };
17 | const add10 = ff001;
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-56.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const ff001 = function ()
6 | {
7 | try
8 | {
9 | return 10;
10 | }
11 | catch (e)
12 | {
13 | console.error({lid: 1235}, e.message);
14 | }
15 | return false;
16 | };
17 | const cc = () =>
18 | {
19 | return add10() * 20;
20 | }
21 | const add10 = ff001;
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-57.mjs:
--------------------------------------------------------------------------------
1 | import {
2 | AnyClass
3 | } from "anylib";
4 | import {
5 | AnyClass
6 | } from "anylib";
7 |
8 |
9 | /**
10 | *
11 | * @returns {boolean}
12 | */
13 | export const ff001 = function ()
14 | {
15 | try
16 | {
17 |
18 | return 10;
19 | }
20 | catch (e)
21 | {
22 | console.error({lid: 1235}, e.message);
23 | }
24 |
25 | return false;
26 | };
27 |
28 | const cc = () =>
29 | {
30 |
31 |
32 | return add10() * 20;
33 | }
34 |
35 |
36 | const add10 = ff001;
37 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-58.mjs:
--------------------------------------------------------------------------------
1 | import {
2 | ns2
3 | } from './file1.mjs';
4 | // const {
5 | // ns1: {ClassA}
6 | // } = require('./file1.cjs');
7 | console.log(`Hi`)
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-7.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-7.cjs]{@link ./assets/given/demo-test-7.cjs}
5 | *
6 | **/
7 | import rgbhex from "./node_modules/rgb-hex-cjs/index.mjs";
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-75.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | export const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | export const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 |
59 |
60 |
61 |
62 | export const ff001 = add10;
63 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-76.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | export const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | export const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 |
59 |
60 |
61 | export const add10 = add40;
62 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-77.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | export const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | export const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 | export const add40 = add10;
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-78.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | export const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | export const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 |
59 |
60 |
61 | export const add40 = add10;
62 | export const add50 = add10;
63 | export const add60 = add30;
64 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-79.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | export const ff001 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | export const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | export const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 |
59 |
60 |
61 |
62 | const add10 = ff001;
63 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-8.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-8.cjs]{@link ./assets/given/demo-test-8.cjs}
5 | *
6 | **/
7 | import rgbhex from "../../node_modules/rgb-hex-cjs/index.mjs";
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-80.mjs:
--------------------------------------------------------------------------------
1 | import fs from "fs";
2 | import path from "path";
3 | import os from "os";
4 | import ansi from "ansi";
5 | import rgb from "rgb";
6 |
7 |
8 |
9 |
10 |
11 | export const ff001 = function () {
12 | try {
13 | return true;
14 | } catch (e) {
15 | console.error({ lid: 1235 }, e.message);
16 | }
17 | return false;
18 | };
19 | export const add20 = function () {
20 | try {
21 | return true;
22 | } catch (e) {
23 | console.error({ lid: 1235 }, e.message);
24 | }
25 | return false;
26 | };
27 | export const add30 = function () {
28 | try {
29 | return true;
30 | } catch (e) {
31 | console.error({ lid: 1235 }, e.message);
32 | }
33 | return false;
34 | };
35 |
36 |
37 |
38 | const add10 = ff001;
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-81.mjs:
--------------------------------------------------------------------------------
1 | import {
2 | AnyClass
3 | } from "anylib";
4 |
5 |
6 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-82.js:
--------------------------------------------------------------------------------
1 | import test2 from "./test2.js";
2 |
3 | test2.doIt();
4 |
5 |
6 | // test2.js
7 |
8 | export default {
9 | doIt: () => {
10 | console.log("hello")
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-9.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./assets/given/demo-test-9.cjs]{@link ./assets/given/demo-test-9.cjs}
5 | *
6 | **/
7 | import rgbhex from "./node_modules/rgb-hex-cjs/index.mjs";
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test-x.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * [./test/assets/given/demo-test-x.cjs]{@link ./test/assets/given/demo-test-x.cjs}
5 | *
6 | **/
7 | import rgbhex from "rgb-hex";;
8 |
9 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test.min.mjs:
--------------------------------------------------------------------------------
1 | console.log("Skip this 3");var o=class{constructor(){console.log("Hello you!")}start(){console.log("I'm ready")}},l=new o,t=new o;console.log(l.example.start());console.log("Skip this 1");console.log("Skip this 2");var e=class{constructor(){console.log("Hello you!")}},r=new e,p=new e;export{r as default,p as example2};
2 |
--------------------------------------------------------------------------------
/test/assets/expect/demo-test.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./demo-test.cjs]{@link ./demo-test.cjs}
5 | *
6 | **/
7 | import {LOG_CONTEXT, LOG_TARGETS} from "./contexts-def.mjs";
8 | import QuickLog from "../../src/cjs/quick-log.mjs";
9 | import QuickLog2 from "../../src/cjs/quick-log.mjs";
10 | import QuickLog3 from "../../src/cjs/quick-log.mjs";
11 | import {COLOR_TABLE, SYSTEM} from "./constants.mjs";
12 |
13 |
14 |
15 |
16 |
17 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
18 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
19 |
20 | QuickLog.setContexts(LOG_CONTEXT);
21 | QuickLog.setTargets(LOG_TARGETS);
22 |
23 |
24 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
25 |
26 |
27 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
28 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
29 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
30 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
31 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
32 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
33 | QuickLog.log(`Basic Log example 1`);
34 | QuickLog2.log(`Basic Log example 1`);
35 | QuickLog3.log(`Basic Log example 1`);
36 |
--------------------------------------------------------------------------------
/test/assets/expect/dump-demo-test-removeResidue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * [./test/assets/given/demo-test-24.cjs]{@link ./test/assets/given/demo-test-24.cjs}
5 | *
6 | **/
7 | import path from "path";
8 | 'use strict';
9 |
10 |
11 | export const add = (a, b)=>
12 | {
13 | return a + b
14 | }
15 |
16 | export default {
17 | add
18 | };
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/assets/expect/html-1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/assets/expect/html-2/index-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/assets/expect/index-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/assets/expect/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/test/assets/expect/other.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 | Title
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/test/assets/expect/package-2.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "main": "./given/demo-test-14.cjs",
4 | "module": "./actual/demo-test-14.mjs",
5 | "type": "module",
6 | "exports": {
7 | ".": {
8 | "require": "./given/demo-test-14.cjs",
9 | "import": "./actual/demo-test-14.mjs"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/package-3.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "main": "./example/cjs/demo.cjs",
4 | "module": "./generated/esm/demo.mjs",
5 | "type": "module",
6 | "exports": {
7 | ".": {
8 | "require": "./given/demo-test-14.cjs",
9 | "import": "./actual/demo-test-14.mjs"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/package-json/package-1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "version": "1.0.2",
4 | "random": 123456,
5 | "main": "./example/demo-test-xx.cjs",
6 | "module": "./actual/demo-test-xx.mjs",
7 | "type": "module",
8 | "exports": {
9 | "require": "./given/demo-test-14.cjs",
10 | "import": "./actual/demo-test-14.mjs"
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/package-json/package-2.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "main": "./given/demo-test-xx.cjs",
4 | "module": "./actual/demo-test-xx.mjs",
5 | "type": "module",
6 | "exports": {
7 | ".": {
8 | "require": "./given/demo-test-14.cjs",
9 | "import": "./actual/demo-test-14.mjs"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/package-json/package-3.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "main": "./example/cjs/demo.cjs",
4 | "module": "./generated/esm/demo.mjs",
5 | "type": "commonjs",
6 | "exports": {
7 | ".": {
8 | "require": "./given/demo-test-14.cjs",
9 | "import": "./actual/demo-test-14.mjs"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/package-json/package-4.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "version": "1.0.2",
4 | "random": 123456,
5 | "main": "./example/demo-test-xx.cjs",
6 | "module": "./actual/demo-test-xx.mjs",
7 | "type": "module",
8 | "exports": {
9 | "require": "./given/demo-test-14.cjs",
10 | "import": "./actual/demo-test-14.mjs"
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "version": "1.0.2",
4 | "random": 123456,
5 | "main": "./example/demo-test-xx.cjs",
6 | "module": "./actual/demo-test-xx.mjs",
7 | "type": "module",
8 | "exports": {
9 | "require": "./given/demo-test-14.cjs",
10 | "import": "./actual/given/demo-test-14.mjs"
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/expect/rgb-hex-cjs-index.mjs:
--------------------------------------------------------------------------------
1 | /**
2 | * DO NOT EDIT THIS FILE DIRECTLY.
3 | * This file is generated following the conversion of
4 | * @see [./node_modules/rgb-hex-cjs/index.js]{@link ./node_modules/rgb-hex-cjs/index.js}
5 | *
6 | **/
7 | 'use strict';
8 | /* eslint-disable no-mixed-operators */
9 | export default (red, green, blue, alpha) => {
10 | const isPercent = (red + (alpha || '')).toString().includes('%');
11 |
12 | if (typeof red === 'string') {
13 | [red, green, blue, alpha] = red.match(/(0?\.?\d{1,3})%?\b/g).map(Number);
14 | } else if (alpha !== undefined) {
15 | alpha = parseFloat(alpha);
16 | }
17 |
18 | if (typeof red !== 'number' ||
19 | typeof green !== 'number' ||
20 | typeof blue !== 'number' ||
21 | red > 255 ||
22 | green > 255 ||
23 | blue > 255
24 | ) {
25 | throw new TypeError('Expected three numbers below 256');
26 | }
27 |
28 | if (typeof alpha === 'number') {
29 | if (!isPercent && alpha >= 0 && alpha <= 1) {
30 | alpha = Math.round(255 * alpha);
31 | } else if (isPercent && alpha >= 0 && alpha <= 100) {
32 | alpha = Math.round(255 * alpha / 100);
33 | } else {
34 | throw new TypeError(`Expected alpha value (${alpha}) as a fraction or percentage`);
35 | }
36 |
37 | alpha = (alpha | 1 << 8).toString(16).slice(1);
38 | } else {
39 | alpha = '';
40 | }
41 |
42 | return ((blue | green << 8 | red << 16) | 1 << 24).toString(16).slice(1) + alpha;
43 | };
44 | /* eslint-enable no-mixed-operators */
45 |
--------------------------------------------------------------------------------
/test/assets/given/.toesm-invalid.json:
--------------------------------------------------------------------------------
1 | {
2 | "replaceStart": [
3 | {
4 | "search" : "/const\\s+ttt\\s*=\\s*require\\(.mama-magnimus.\\);/g",
5 | "replace": "// ***"
6 | }
7 | ],
8 | "replaceEnd" : [
9 | {
10 | "search" : "// ***",
11 | "replace": "// --------- mama-magnimus was replaced ----------------"
12 | }
13 | ],
14 | "html" :
15 | {
16 | "importmapReplace": [{
17 | "search" : "./anywhere",
18 | "replace": "/foundwhere",
19 | "regex": false
20 | }]
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/test/assets/given/.toesm-nohtml-pattern.json:
--------------------------------------------------------------------------------
1 | {
2 | "replaceStart": [
3 | {
4 | "search" : "/const\\s+ttt\\s*=\\s*require\\(.mama-magnimus.\\);/g",
5 | "replace": "// ***"
6 | }
7 | ],
8 | "replaceEnd" : [
9 | {
10 | "search" : "// ***",
11 | "replace": "// --------- mama-magnimus was replaced ----------------"
12 | }
13 | ],
14 | "replaceModules":
15 | {
16 | "color-convert": {
17 | "cjs": {
18 | "name": "color-convert-cjs",
19 | "version": "@^3.0.0"
20 | },
21 | "esm": {
22 | "version": "@latest"
23 | }
24 | }
25 | },
26 | "html":
27 | {
28 | "importmap": {
29 | },
30 | "importmapReplace": [{
31 | "search" : "node0000_modules",
32 | "replace": "../node000_modules"
33 | }],
34 | "overwriteim": true
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/test/assets/given/.toesm-replace-modules.json:
--------------------------------------------------------------------------------
1 | {
2 | "replaceStart": [
3 | {
4 | "search": "/const\\s+ttt\\s*=\\s*require\\(.mama-magnimus.\\);/g",
5 | "replace": "// ***"
6 | }
7 | ],
8 | "replaceEnd": [
9 | {
10 | "search": "// ***",
11 | "replace": "// --------- mama-magnimus was replaced ----------------"
12 | }
13 | ],
14 | "replaceModules": {
15 | "rgb-hex": {
16 | "cjs": {
17 | "name": "rgb-hex-cjs",
18 | "version": "@^3.0.0"
19 | },
20 | "esm": {
21 | "version": "@latest"
22 | }
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/test/assets/given/.toesm.json:
--------------------------------------------------------------------------------
1 | {
2 | "replaceStart": [
3 | {
4 | "search" : "/const\\s+ttt\\s*=\\s*require\\(.mama-magnimus.\\);/g",
5 | "replace": "// ***"
6 | }
7 | ],
8 | "replaceEnd" : [
9 | {
10 | "search" : "// ***",
11 | "replace": "// --------- mama-magnimus was replaced ----------------"
12 | }
13 | ],
14 | "html" :
15 | {
16 | "importmap" : {
17 | "ttt2": "http://somewhere",
18 | "ttt": "http://anywhere"
19 | },
20 | "importmapReplace": [{
21 | "search" : "./anywhere",
22 | "replace": "/foundwhere",
23 | "regex": false
24 | }]
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/test/assets/given/analogger/constants.cjs:
--------------------------------------------------------------------------------
1 | const constants = {
2 | COLOR_TABLE: [
3 | "#d2466e", // Error context color
4 | "#FFA07A", // Default context color
5 | "#FF7F50",
6 | "#FF6347",
7 | "#FFE4B5",
8 | "#ADFF2F",
9 | "#808000",
10 | "#40E0D0",
11 | "#1E90FF",
12 | "#EE82EE",
13 | "#708090",
14 | "#DEB887",
15 | "#FE642E",
16 | "#210B61",
17 | "#088A4B",
18 | "#5E610B",
19 | "#FA8258",
20 | "#088A68",
21 | "#B40431",
22 | ],
23 | SYSTEM: {
24 | BROWSER: "BROWSER",
25 | NODE: "NODE"
26 | }
27 |
28 | };
29 |
30 | module.exports.COLOR_TABLE = constants.COLOR_TABLE;
31 | module.exports.SYSTEM = constants.SYSTEM;
--------------------------------------------------------------------------------
/test/assets/given/case-1/deep1/deep2/deep3/models/example-1/more/contexts-def.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @type {{C3: null, TEST: {symbol: string, color: string}, STANDARD: {}, C1: null, DEFAULT: {}, C2: null}}
4 | */
5 | module.exports.LOG_CONTEXTS = {
6 | STANDARD: {},
7 | TEST: {color: "#B18904", symbol: "⏰"},
8 | TEST2: {color: "rgb(127, 127, 127)", symbol: "⏰"},
9 | TEST3: {color: "blue", symbol: "⏰"},
10 | C1: null,
11 | C2: null,
12 | C3: null,
13 | INFO: {},
14 | DEFAULT: {}
15 | };
16 |
17 | module.exports.LOG_TARGETS = {ALL: "ALL", DEV1: "TOM", DEV2: "TIM", DEV3: "ME", USER: "USER"};
--------------------------------------------------------------------------------
/test/assets/given/case-1/deep1/deep2/deep3/models/example-1/more/something/dummy.cjs:
--------------------------------------------------------------------------------
1 | const t1 = require("../../../../unrelated/t1-cjs.cjs");
2 | const t2 = require("../../../../unrelated/t2.js");
3 | const t3 = require("../../../../unrelated/t3.mjs");
4 |
5 | const t4 = require("../../../../unrelated/deep1/t4-cjs.cjs");
6 | const t5 = require("../../../../unrelated/deep1/t5.js");
7 | const t6 = require("../../../../unrelated/deep1/t6.mjs");
8 |
9 | const t7 = require("../../../../unrelated/deep1/deep2/t7-cjs.cjs");
10 | const t8 = require("../../../../unrelated/deep1/deep2/t8.js");
11 | const t9 = require("../../../../unrelated/deep1/deep2/t9.mjs");
12 |
13 |
14 | console.log(t1, t2, t3, t4, t5, t6, t7, t8, t9);
15 |
--------------------------------------------------------------------------------
/test/assets/given/case-1/deep1/deep2/deep3/models/example-1/more/something/dummy.cjs.js:
--------------------------------------------------------------------------------
1 | const t1 = require("../../../../unrelated/t1-cjs.cjs");
2 | const t2 = require("../../../../unrelated/t2.js");
3 | const t3 = require("../../../../unrelated/t3.mjs");
4 |
5 | const t4 = require("../../../../unrelated/deep1/t4-cjs.cjs");
6 | const t5 = require("../../../../unrelated/deep1/t5.js");
7 | const t6 = require("../../../../unrelated/deep1/t6.mjs");
8 |
9 | const t7 = require("../../../../unrelated/deep1/deep2/t7-cjs.cjs");
10 | const t8 = require("../../../../unrelated/deep1/deep2/t8.js");
11 | const t9 = require("../../../../unrelated/deep1/deep2/t9.mjs");
12 |
13 |
14 | console.log(t1, t2, t3, t4, t5, t6, t7, t8, t9);
15 |
--------------------------------------------------------------------------------
/test/assets/given/case-1/deep1/deep2/deep3/models/example-1/more/something/dummy.js:
--------------------------------------------------------------------------------
1 | const t1 = require("../../../../unrelated/t1-cjs.cjs");
2 | const t2 = require("../../../../unrelated/t2.js");
3 | const t3 = require("../../../../unrelated/t3.mjs");
4 |
5 | const t4 = require("../../../../unrelated/deep1/t4-cjs.cjs");
6 | const t5 = require("../../../../unrelated/deep1/t5.js");
7 | const t6 = require("../../../../unrelated/deep1/t6.mjs");
8 |
9 | const t7 = require("../../../../unrelated/deep1/deep2/t7-cjs.cjs");
10 | const t8 = require("../../../../unrelated/deep1/deep2/t8.js");
11 | const t9 = require("../../../../unrelated/deep1/deep2/t9.mjs");
12 |
13 |
14 | console.log(t1, t2, t3, t4, t5, t6, t7, t8, t9);
15 |
--------------------------------------------------------------------------------
/test/assets/given/case-1/deep1/deep2/deep3/src/constants.cjs:
--------------------------------------------------------------------------------
1 | const constants = {
2 | COLOR_TABLE: [
3 | "#d2466e", // Error context color
4 | "#FFA07A", // Default context color
5 | "#FF7F50",
6 | "#FF6347",
7 | "#FFE4B5",
8 | "#ADFF2F",
9 | "#808000",
10 | "#40E0D0",
11 | "#1E90FF",
12 | "#EE82EE",
13 | "#708090",
14 | "#DEB887",
15 | "#FE642E",
16 | "#210B61",
17 | "#088A4B",
18 | "#5E610B",
19 | "#FA8258",
20 | "#088A68",
21 | "#B40431",
22 | ],
23 | SYSTEM: {
24 | BROWSER: "BROWSER",
25 | NODE: "NODE"
26 | }
27 |
28 | };
29 |
30 | module.exports.COLOR_TABLE = constants.COLOR_TABLE;
31 | module.exports.SYSTEM = constants.SYSTEM;
32 | module.exports.MAX_CHILDREN_DOM_ANALOGGER = 2000;
33 | module.exports.CLASS_REMOVED_NOTIF = "analogger-removed-notif";
34 | module.exports.CONSOLE_AREA_CLASSNAME = "analogger-view";
35 | module.exports.LINE_CLASSNAME = "to-esm-line";
36 |
37 | module.exports.ADD_TYPE = {
38 | TOP: "TOP",
39 | BOTTOM: "BOTTOM"
40 | };
41 |
42 | const ANALOGGER_NAME = "ANALOGGER";
43 |
44 | module.exports.ANALOGGER_NAME = ANALOGGER_NAME;
45 |
46 | module.exports.PREDEFINED_FORMATS = {
47 | DEFAULT_FORMAT: "FORMAT1"
48 | };
49 |
--------------------------------------------------------------------------------
/test/assets/given/case-2/plan-1/models/example-1/more/contexts-def.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @type {{C3: null, TEST: {symbol: string, color: string}, STANDARD: {}, C1: null, DEFAULT: {}, C2: null}}
4 | */
5 | module.exports.LOG_CONTEXTS = {
6 | STANDARD: {},
7 | TEST: {color: "#B18904", symbol: "⏰"},
8 | TEST2: {color: "rgb(127, 127, 127)", symbol: "⏰"},
9 | TEST3: {color: "blue", symbol: "⏰"},
10 | C1: null,
11 | C2: null,
12 | C3: null,
13 | INFO: {},
14 | DEFAULT: {}
15 | };
16 |
17 | module.exports.LOG_TARGETS = {ALL: "ALL", DEV1: "TOM", DEV2: "TIM", DEV3: "ME", USER: "USER"};
--------------------------------------------------------------------------------
/test/assets/given/case-2/plan-1/models/example-1/more/something/dummy.cjs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/test/assets/given/case-2/plan-1/models/example-1/more/something/dummy.cjs
--------------------------------------------------------------------------------
/test/assets/given/case-2/plan-1/models/example-1/more/something/dummy.cjs.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/test/assets/given/case-2/plan-1/models/example-1/more/something/dummy.cjs.js
--------------------------------------------------------------------------------
/test/assets/given/case-2/plan-1/models/example-1/more/something/dummy.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/test/assets/given/case-2/plan-1/models/example-1/more/something/dummy.js
--------------------------------------------------------------------------------
/test/assets/given/case-2/plan-1/src/constants.cjs:
--------------------------------------------------------------------------------
1 | const constants = {
2 | COLOR_TABLE: [
3 | "#d2466e", // Error context color
4 | "#FFA07A", // Default context color
5 | "#FF7F50",
6 | "#FF6347",
7 | "#FFE4B5",
8 | "#ADFF2F",
9 | "#808000",
10 | "#40E0D0",
11 | "#1E90FF",
12 | "#EE82EE",
13 | "#708090",
14 | "#DEB887",
15 | "#FE642E",
16 | "#210B61",
17 | "#088A4B",
18 | "#5E610B",
19 | "#FA8258",
20 | "#088A68",
21 | "#B40431",
22 | ],
23 | SYSTEM: {
24 | BROWSER: "BROWSER",
25 | NODE: "NODE"
26 | }
27 |
28 | };
29 |
30 | module.exports.COLOR_TABLE = constants.COLOR_TABLE;
31 | module.exports.SYSTEM = constants.SYSTEM;
32 | module.exports.MAX_CHILDREN_DOM_ANALOGGER = 2000;
33 | module.exports.CLASS_REMOVED_NOTIF = "analogger-removed-notif";
34 | module.exports.CONSOLE_AREA_CLASSNAME = "analogger-view";
35 | module.exports.LINE_CLASSNAME = "to-esm-line";
36 |
37 | module.exports.ADD_TYPE = {
38 | TOP: "TOP",
39 | BOTTOM: "BOTTOM"
40 | };
41 |
42 | const ANALOGGER_NAME = "ANALOGGER";
43 |
44 | module.exports.ANALOGGER_NAME = ANALOGGER_NAME;
45 |
46 | module.exports.PREDEFINED_FORMATS = {
47 | DEFAULT_FORMAT: "FORMAT1"
48 | };
49 |
--------------------------------------------------------------------------------
/test/assets/given/common/data-exchanger.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "EVENT_MESSAGE_FROM_PRELOAD_TO_RENDERER": "A003_EVENT_MESSAGE_FROM_PRELOAD_TO_RENDERER",
3 | "RESPONSE_MESSAGE_FROM_RENDERER_TO_PRELOAD": "A004_RESPONSE_MESSAGE_FROM_RENDERER_TO_PRELOAD",
4 |
5 | "RESPONSE_MESSAGE_FROM_PRELOAD_TO_RENDERER": "A006_RESPONSE_MESSAGE_FROM_PRELOAD_TO_RENDERER",
6 |
7 | "MAIN_CHANNEL_DATA": "A007_MYEVENT",
8 | "CONSOLE_ESM": "color: #A5AF8A",
9 | "CONSOLE_CJS": "color: #F5A65A",
10 | "CONSOLE_SUCCESS": "color: yellow",
11 |
12 | "CHANNEL_MESSAGE_PREFIX": "data-message-",
13 | "CHANNEL_RESPONSE_PREFIX": "data-response-",
14 |
15 | "EXCHANGE_DIV_ID_UP": "UP-434-AssGK2154G2RE-4554",
16 | "EXCHANGE_DIV_ID_DOWN": "DOWN-434-AssGK2154G2RE-4554",
17 |
18 | "PREFIX_MESSAGE": "message-",
19 | "PREFIX_RESPONSE": "response-",
20 |
21 | "SUFFIX_TEST": "___test___Request",
22 |
23 | "EXCHANGER_TYPE": {
24 | "UP": "UP",
25 | "DOWN": "DOWN"
26 | }
27 | }
--------------------------------------------------------------------------------
/test/assets/given/common/specificities.cjs:
--------------------------------------------------------------------------------
1 | const SPECIFICS = {
2 | DIRECTION: {
3 | UP : "UP", // UP: Renderer => Preloader => Main Process
4 | DOWN: "DOWN" // DOWN: Main Process => Preloader => Renderer
5 | },
6 | MESSAGE_TYPE: {
7 | MESSAGE: "MESSAGE",
8 | RESPONSE: "RESPONSE"
9 | },
10 | SYSTEM_TYPE: {
11 | PRELOADER: "PRELOADER",
12 | RENDERER: " RENDERER", // The extra space is for the console alignment. Can be removed safely in case of problem.
13 | MAIN: "MAIN",
14 | UNKNOWN: "UNKNOWN"
15 | }
16 |
17 | };
18 |
19 | module.exports.DIRECTION = SPECIFICS.DIRECTION;
20 | module.exports.MESSAGE_TYPE = SPECIFICS.MESSAGE_TYPE;
21 | module.exports.SYSTEM_TYPE = SPECIFICS.SYSTEM_TYPE;
22 | module.exports = SPECIFICS;
23 |
24 |
--------------------------------------------------------------------------------
/test/assets/given/demo-bad-syntax.cjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | var QuickLog4 = "rr";
7 |
8 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
9 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
10 |
11 | QuickLog4 = require("../../src/cjs/quick-log.cjs")
12 |
13 | let myLog1, QuickLog5, yourLog;
14 | let myLog2, QuickLog6, yourLog2;
15 | let QuickLog7, myLog2, yourLog2;
16 |
17 | QuickLog.setContexts(LOG_CONTEXT);
18 | QuickLog.setTargets(LOG_TARGETS);
19 |
20 | QuickLog5 = require("../../src/cjs/quick-log.cjs");
21 | QuickLog6 = require("../../src/cjs/quick-log.cjs")
22 | QuickLog7 = require("../../src/cjs/quick-log.cjs")
23 |
24 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
25 |
26 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
27 |
28 |
29 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
30 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
31 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
32 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
33 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
34 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
35 | QuickLog.log(`Basic Log example 1`);
36 | QuickLog2.log(`Basic Log example 1`);
37 | QuickLog3.log(`Basic Log example 1`);
38 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-10.cjs:
--------------------------------------------------------------------------------
1 | const rgbhex = require("rgb-hex-cjs");
2 |
3 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-11.cjs:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-12.cjs:
--------------------------------------------------------------------------------
1 | /** to-esm-browser: remove **/
2 | const path = require("path");
3 | const fs = require("fs");
4 | const os = require("os");
5 | /** to-esm-browser: end-remove **/
6 |
7 | abc/** to-esm-all: skip **/
8 | const path = require("path1");
9 | /** to-esm-all: end-skip **/def
10 |
11 | const rgbHex = require("rgb-hex-cjs");
12 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
13 |
14 | const EOL =`
15 | `;
16 |
17 | ghi/** to-esm-esm: skip **/
18 | const path = require("path2");
19 | /** to-esm-esm: end-skip **/jkl
20 |
21 | mno/** to-esm-browser: skip **/
22 | const path = require("path3");
23 | /** to-esm-browser: end-skip **/pqr
24 |
25 |
26 | class Example
27 | {
28 |
29 | }
30 |
31 |
32 | /** to-esm-all: add
33 | console.log("1- LogToFile is not supported in this environment. ")
34 | **/
35 |
36 | /** to-esm-browser: add
37 | console.log("2- LogToFile is not supported in this environment. ")
38 | **/
39 |
40 | /** to-esm-esm: add
41 | console.log("3- LogToFile is not supported in this environment. ")
42 | **/
43 |
44 | module.exports = new Example();
45 | module.exports.anaLogger = new Example();
46 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-13-bis.cjs:
--------------------------------------------------------------------------------
1 | /** to-esm-browser: remove **/
2 | const path = require("path");
3 | const fs = require("fs");
4 | /** to-esm-browser: end-remove **/
5 |
6 | /** to-esm-esm: remove **/
7 | const os = require("os");
8 | /** to-esm-esm: end-remove **/
9 |
10 | abc/** to-esm-browser: skip **/
11 | console.log("Skip this 1");
12 | /** to-esm-all: end-skip **/def
13 |
14 | const rgbHex = require("rgb-hex-cjs");
15 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
16 |
17 | /** to-esm-all: add
18 | console.log("1- LogToFile is not supported in this environment. ")
19 | **/
20 |
21 | /** to-esm-esm: add
22 | console.log("2- LogToFile is not supported in this environment. ")
23 | **/
24 |
25 | /** to-esm-browser: add
26 | console.log("3- LogToFile is not supported in this environment. ")
27 | **/
28 |
29 | const EOL =`
30 | `;
31 |
32 | ghi/** to-esm-all: skip **/
33 | console.log("Skip this 2");
34 | /** to-esm-all: end-skip **/jkl
35 |
36 |
37 | class Example
38 | {
39 |
40 | }
41 |
42 | module.exports = new Example();
43 | module.exports.anaLogger = new Example();
44 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-13.cjs:
--------------------------------------------------------------------------------
1 | /** to-esm-all: remove **/
2 | const path = require("path");
3 | const fs = require("fs");
4 | const os = require("os");
5 | /** to-esm-all: end-remove **/
6 |
7 | abc/** to-esm-all: skip **/
8 | console.log("Skip this 1");
9 | /** to-esm-all: end-skip **/def
10 |
11 | const rgbHex = require("rgb-hex-cjs");
12 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
13 |
14 | /** to-esm-all: add
15 | console.log("1- LogToFile is not supported in this environment. ")
16 | **/
17 |
18 | /** to-esm-browser: add
19 | console.log("2- LogToFile is not supported in this environment. ")
20 | **/
21 |
22 | /** to-esm-browser: add
23 | console.log("3- LogToFile is not supported in this environment. ")
24 | **/
25 |
26 | const EOL =`
27 | `;
28 |
29 | ghi/** to-esm-browser: skip **/
30 | console.log("Skip this 2");
31 | /** to-esm-browser: end-skip **/jkl
32 |
33 |
34 | class Example
35 | {
36 |
37 | }
38 |
39 | module.exports = new Example();
40 | module.exports.anaLogger = new Example();
41 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-14.cjs:
--------------------------------------------------------------------------------
1 | /** to-esm-browser: remove **/
2 | const path = require("path");
3 | const fs = require("fs");
4 | const os = require("os");
5 | /** to-esm-browser: end-remove **/
6 |
7 | const stuff = require("./demo-test-15.cjs");
8 |
9 | console.log(stuff.example.start())
10 |
11 | /** to-esm-all: skip **/
12 | console.log("Skip this 1");
13 | /** to-esm-all: end-skip **/
14 |
15 | const EOL =`
16 | `;
17 |
18 | /** to-esm-all: skip **/
19 | console.log("Skip this 2");
20 | /** to-esm-all: end-skip **/
21 |
22 |
23 | class Example2
24 | {
25 | constructor()
26 | {
27 | console.log("Hello you!");
28 | }
29 | }
30 |
31 | module.exports = new Example2();
32 | module.exports.example2 = new Example2();
33 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-15.cjs:
--------------------------------------------------------------------------------
1 | const EOL =`
2 | `;
3 |
4 | /** to-esm-all: skip **/
5 | console.log("Skip this 3");
6 | /** to-esm-all: end-skip **/
7 |
8 |
9 | class Example
10 | {
11 | constructor()
12 | {
13 | console.log("Hello you!");
14 | }
15 |
16 | start()
17 | {
18 | console.log("I'm ready")
19 | }
20 | }
21 |
22 | module.exports = new Example();
23 | module.exports.example = new Example();
24 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-19.cjs:
--------------------------------------------------------------------------------
1 | /** code example extracted from a Node module **/
2 | 'use strict';
3 |
4 | // Export FSWatcher class
5 | exports.FSWatcher = FSWatcher;
6 |
7 | /**
8 | * Instantiates watcher with paths to be tracked.
9 | * @param {String|Array} paths file/directory paths and/or globs
10 | * @param {Object=} options chokidar opts
11 | * @returns an instance of FSWatcher for chaining.
12 | */
13 | const watch = (paths, options) => {
14 | const watcher = new FSWatcher(options);
15 | watcher.add(paths);
16 | return watcher;
17 | };
18 |
19 | exports.watch = watch;
20 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-22.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | * Some code extract from module to use with test only
3 | */
4 | 'use strict';
5 |
6 | const { EMPTY_BUFFER } = require('./constants');
7 |
8 | function concat(list, totalLength) {
9 | }
10 |
11 | /**
12 | * Some comment
13 | *
14 | */
15 | function _mask(source, mask, output, offset, length) {
16 | for (let i = 0; i < length; i++) {
17 | output[offset + i] = source[i] ^ mask[i & 3];
18 | }
19 | }
20 |
21 | function _unmask(buffer, mask) {
22 | for (let i = 0; i < buffer.length; i++) {
23 | buffer[i] ^= mask[i & 3];
24 | }
25 | }
26 |
27 | function toArrayBuffer(buf) {
28 | if (buf.byteLength === buf.buffer.byteLength) {
29 | return buf.buffer;
30 | }
31 |
32 | return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
33 | }
34 |
35 | /**
36 | * Converts `data` to a `Buffer`.
37 | *
38 | * @param {*} data The data to convert
39 | * @return {Buffer} The buffer
40 | * @throws {TypeError}
41 | * @public
42 | */
43 | function toBuffer(data) {
44 |
45 | return buf;
46 | }
47 |
48 | try {
49 | module.exports = require('node-gyp-build')(__dirname);
50 | } catch (e) {
51 | module.exports = require('./fallback');
52 | }
53 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-23.cjs:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | //
4 | // Allowed token characters:
5 | //
6 | // '!', '#', '$', '%', '&', ''', '*', '+', '-',
7 | // '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~'
8 | //
9 | // tokenChars[32] === 0 // ' '
10 | // tokenChars[33] === 1 // '!'
11 | // tokenChars[34] === 0 // '"'
12 | // ...
13 | //
14 | // prettier-ignore
15 |
16 | const isValidUTF8 = require('utf-8-validate');
17 | module.exports = {
18 | isValidStatusCode,
19 | isValidUTF8(buf)
20 | {
21 | return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
22 | },
23 | tokenChars
24 | };
25 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-24.cjs:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path');
4 |
5 | const add = (a, b)=>
6 | {
7 | return a + b
8 | }
9 |
10 | module.exports = {
11 | add
12 | };
13 |
14 | module.exports.add = add;
15 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-27.cjs:
--------------------------------------------------------------------------------
1 | exports = module.exports = stringify
2 | exports.getSerialize = serializer
3 |
4 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-3.cjs:
--------------------------------------------------------------------------------
1 | /** const chalk001 = require("chalk-cjs"); **/
2 | const chalk000 = require("chalk-cjs"); // const path = require("path");
3 | // const chalk002 = require("chalk-cjs");
4 | const aa = "const chalk003 = require(\"chalk-cjs\");"
5 | const magnimus = require("mama-magnimus");
6 | const magnimus2 = require("mama-magnimus-cjs");
7 | const rgbhex = /** Cool **/ require("rgb-hex-cjs");
8 | const INFO1 = require("./dep-1.cjs");
9 | const INFO2 = require("./dep-2.cjs");
10 | const INFO3 = require('./dep-3.js');
11 | const bb = `
12 | const chalk004 = require("chalk-cjs");
13 |
14 | const chalk005 = require("chalk-cjs");
15 | `
16 | const INFO4 = require("./something.js");
17 | const INFO5 = require("./something.cjs");
18 | const path = require("path");
19 |
20 | /**
21 | * Multi line comment
22 | */
23 | const {DIRECTION, MESSAGE} = require("./dep-1");
24 |
25 | // ----
26 |
27 | /**
28 | * @class SomeClass
29 | */
30 | class SomeClass
31 | {
32 | constructor()
33 | {
34 | console.log(DIRECTION)
35 | console.log(MESSAGE)
36 | console.log(INFO1)
37 | }
38 | }
39 |
40 | module.exports = SomeClass;
--------------------------------------------------------------------------------
/test/assets/given/demo-test-31.cjs:
--------------------------------------------------------------------------------
1 | /** to-esm-browser: remove **/
2 | const path = require("path");
3 | const fs = require("fs");
4 | const os = require("os");
5 | /** to-esm-browser: end-remove **/
6 |
7 | abc/** to-esm-all: skip **/
8 | const path = require("path1");
9 | /** to-esm-all: end-skip **/def
10 |
11 | const rgbHex = require("rgb-hex-cjs");
12 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
13 |
14 | const EOL =`
15 | `;
16 |
17 | ghi/** to-esm-esm: skip **/
18 | const path = require("path2");
19 | /** to-esm-esm: end-skip **/jkl
20 |
21 | mno/** to-esm-browser: skip **/
22 | const path = require("path3");
23 | /** to-esm-browser: end-skip **/pqr
24 |
25 |
26 | class Example
27 | {
28 |
29 | }
30 |
31 |
32 | /** to-esm-all: add
33 | console.log("1- LogToFile is not supported in this environment. ")
34 | **/
35 |
36 | /** to-esm-browser: add
37 | console.log("2- LogToFile is not supported in this environment. ")
38 | **/
39 |
40 | /** to-esm-esm: add
41 | console.log("3- LogToFile is not supported in this environment. ")
42 | **/
43 |
44 | module.exports = new Example();
45 | module.exports.anaLogger = new Example();
46 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-33.cjs:
--------------------------------------------------------------------------------
1 | // Load a library only CJS compatible
2 | const commonDir = require("commondir");
3 |
4 | // Load hybrid library
5 | const toAnsi = require("to-ansi");
6 |
7 | const CommonFeatureExchanger = require("./common/common-feature-exchanger.cjs");
8 | const DATA_EXCHANGE_INFO = require("./common/data-exchanger.cjs");
9 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-34.cjs:
--------------------------------------------------------------------------------
1 | // Load a library only CJS compatible
2 | const commonDir = require("commondir");
3 |
4 | // Load hybrid library
5 | const toAnsi = require("to-ansi");
6 |
7 | const CommonFeatureExchanger = require("./common/common-feature-exchanger.cjs");
8 | const DATA_EXCHANGE_INFO = require("./common/data-exchanger.cjs");
9 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-36.cjs:
--------------------------------------------------------------------------------
1 | // const pingServer
2 | const pingServer = function()
3 | {
4 | };
5 |
6 | module.exports.pingServer = pingServer;
7 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-37.cjs:
--------------------------------------------------------------------------------
1 | module.exports = something;
2 | module.exports.default = something;
--------------------------------------------------------------------------------
/test/assets/given/demo-test-38.cjs:
--------------------------------------------------------------------------------
1 | // #!/usr/bin/env node
2 |
3 | const {findPackageEntryPoint} = require("to-ansi");
4 |
5 | const argv = minimist(process.argv.slice(2));
6 |
7 | const init = (argv) =>
8 | {
9 | const name = argv.name;
10 | const dirpath = argv.path;
11 | const target = argv.target;
12 |
13 | let isCjs = false, isModule = false, isBrowser = false;
14 | if (target === "browser")
15 | {
16 | isBrowser = true;
17 | }
18 | else if (target === "esm")
19 | {
20 | isModule = true;
21 | }
22 | else if (target === "cjs")
23 | {
24 | isCjs = true;
25 | }
26 |
27 | const entrypoint =
28 | findPackageEntryPoint(name, dirpath, {isCjs, isModule, isBrowser});
29 |
30 | if (!entrypoint)
31 | {
32 | console.log("No entrypoint detected on this module/path");
33 | return;
34 | }
35 |
36 | console.log(entrypoint);
37 | };
38 |
39 | init(argv);
--------------------------------------------------------------------------------
/test/assets/given/demo-test-4.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | const SPECIAL_CONSTANTS = {
4 | WELCOME_CONTENT: "Welcome",
5 | };
6 |
7 | const SPECIAL_CONSTANTS_2 = {
8 | COMMAND_NOT_SENT : "COMMAND_NOT_SENT",
9 | };
10 |
11 | module.exports = {SPECIAL_CONSTANTS, SPECIAL_CONSTANTS_2};
--------------------------------------------------------------------------------
/test/assets/given/demo-test-40.cjs:
--------------------------------------------------------------------------------
1 | let _terminalSize = {};
2 |
3 | /** to-esm-esm: remove **/
4 | const path = require("path");
5 | const fs = require("fs");
6 | let terminalSize = require("window-size");
7 | _terminalSize = terminalSize;
8 | /** to-esm-esm: end-remove **/
9 |
10 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-41.cjs:
--------------------------------------------------------------------------------
1 | let _terminalSize = {};
2 |
3 | /** to-esm-esm: remove **/
4 | const path = require("path");
5 | const fs = require("fs");
6 | let terminalSize = require("window-size");
7 | _terminalSize = terminalSize;
8 | /** to-esm-esm: end-remove **/
9 |
10 | /** to-esm-esm: add
11 | let congrats = {}
12 | **/
13 |
14 | /** to-esm-browser: skip **/
15 | // Comment 1
16 | let say = "good morning";
17 | const os = require("os");
18 | /** to-esm-browser: end-skip **/
19 |
20 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-43.cjs:
--------------------------------------------------------------------------------
1 |
2 | const MyClass = require("/projects/to-esm/test/assets/given/my-test-class.cjs");
3 |
4 | const instance = new MyClass();
5 | instance.someMethod();
6 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-44.cjs:
--------------------------------------------------------------------------------
1 |
2 | const escapeDollar = (text) =>
3 | {
4 | return text.split("$").join("$$");
5 | };
6 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-46.mjs:
--------------------------------------------------------------------------------
1 |
2 |
3 | import toAnsi from "/to-ansi/index.mjs";
--------------------------------------------------------------------------------
/test/assets/given/demo-test-5.cjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | var QuickLog4 = "rr";
7 |
8 | let some1 = require("./demo-test-2.cjs");
9 | var some2 = require("./demo-test-3");
10 |
11 |
12 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
13 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
14 |
15 | QuickLog4 = require("../../src/cjs/quick-log.cjs")
16 |
17 | let myLog1, QuickLog5, yourLog;
18 | let myLog2, QuickLog6, yourLog2;
19 | let QuickLog7, yourLog2;
20 |
21 | QuickLog.setContexts(LOG_CONTEXT);
22 | QuickLog.setTargets(LOG_TARGETS);
23 |
24 | QuickLog5 = require("../../src/cjs/quick-log.cjs");
25 | QuickLog6 = require("../../src/cjs/quick-log.cjs")
26 | QuickLog7 = require("../../src/cjs/quick-log.cjs")
27 |
28 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
29 |
30 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
31 |
32 |
33 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
34 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
35 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
36 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
37 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
38 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
39 | QuickLog.log(`Basic Log example 1`);
40 | QuickLog2.log(`Basic Log example 1`);
41 | QuickLog3.log(`Basic Log example 1`);
42 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-52.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @param serverUrl
4 | * @param delay
5 | * @param {"firefox"|"google chrome"|""} browserName
6 | * @param args
7 | * @returns {Promise}
8 | */
9 | async function openUrl(serverUrl, {delay = 1000, browserName = "", args = []} = {})
10 | {
11 | try
12 | {
13 | let options = {};
14 |
15 | if (browserName)
16 | {
17 | options.app = {name: browserName};
18 | }
19 |
20 | if (args && args.length)
21 | {
22 | options.arguments = args;
23 | }
24 |
25 | await open(serverUrl, options);
26 | await sleep(delay);
27 |
28 | return true;
29 | }
30 | catch (e)
31 | {
32 | console.error({lid: 3361}, e.message);
33 | }
34 |
35 | return false;
36 | }
37 |
38 |
39 | module.exports.openUrl = openUrl;
--------------------------------------------------------------------------------
/test/assets/given/demo-test-55.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | module.exports.ff001 = add10;
21 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-56.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return 10;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | const cc = () =>
21 | {
22 | return add10() * 20;
23 | }
24 |
25 | module.exports.ff001 = add10;
26 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-57.cjs:
--------------------------------------------------------------------------------
1 | const {
2 | AnyClass
3 | } = require('anylib');
4 |
5 | /**
6 | *
7 | * @returns {boolean}
8 | */
9 | const add10 = function ()
10 | {
11 | try
12 | {
13 |
14 | return 10;
15 | }
16 | catch (e)
17 | {
18 | console.error({lid: 1235}, e.message);
19 | }
20 |
21 | return false;
22 | };
23 |
24 | const cc = () =>
25 | {
26 | const {
27 | AnyClass
28 | } = require('anylib');
29 |
30 | return add10() * 20;
31 | }
32 |
33 | module.exports.ff001 = add10;
34 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-58.cjs:
--------------------------------------------------------------------------------
1 | // const {
2 | // ns1: {ClassA}
3 | // } = require('./file1.cjs');
4 |
5 | const {
6 | ns2
7 | } = require('./file1.cjs');
8 |
9 | console.log(`Hi`)
--------------------------------------------------------------------------------
/test/assets/given/demo-test-7.cjs:
--------------------------------------------------------------------------------
1 | const rgbhex = require("rgb-hex-cjs");
2 |
3 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-75.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 | module.exports.add10 = add10;
59 | module.exports.add20 = add20;
60 | module.exports.add30 = add30;
61 |
62 | module.exports.ff001 = add10;
63 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-76.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 | module.exports.add10 = add10;
59 | module.exports.add20 = add20;
60 | module.exports.add30 = add30;
61 | module.exports.add10 = add40;
62 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-77.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 | const add40 = add10;
59 |
60 | module.exports.add10 = add10;
61 | module.exports.add20 = add20;
62 | module.exports.add30 = add30;
63 | module.exports.add40 = add40;
64 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-78.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 | module.exports.add10 = add10;
59 | module.exports.add20 = add20;
60 | module.exports.add30 = add30;
61 | module.exports.add40 = add10;
62 | module.exports.add50 = add10;
63 | module.exports.add60 = add30;
64 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-79.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @returns {boolean}
4 | */
5 | const add10 = function ()
6 | {
7 | try
8 | {
9 |
10 | return true;
11 | }
12 | catch (e)
13 | {
14 | console.error({lid: 1235}, e.message);
15 | }
16 |
17 | return false;
18 | };
19 |
20 | /**
21 | *
22 | * @returns {boolean}
23 | */
24 | const add20 = function ()
25 | {
26 | try
27 | {
28 |
29 | return true;
30 | }
31 | catch (e)
32 | {
33 | console.error({lid: 1235}, e.message);
34 | }
35 |
36 | return false;
37 | };
38 |
39 | /**
40 | *
41 | * @returns {boolean}
42 | */
43 | const add30 = function ()
44 | {
45 | try
46 | {
47 |
48 | return true;
49 | }
50 | catch (e)
51 | {
52 | console.error({lid: 1235}, e.message);
53 | }
54 |
55 | return false;
56 | };
57 |
58 | module.exports.add20 = add20;
59 | module.exports.add30 = add30;
60 |
61 | exports.ff001 = add10;
62 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-8.cjs:
--------------------------------------------------------------------------------
1 | const rgbhex = require("rgb-hex-cjs");
2 |
3 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-80.cjs:
--------------------------------------------------------------------------------
1 | const fs = require("fs"), path = require("path"), os = require("os");
2 | const ansi = require("ansi"), rgb = require("rgb");
3 |
4 |
5 | /**
6 | *
7 | * @returns {boolean}
8 | */
9 | const add10 = function ()
10 | {
11 | try
12 | {
13 |
14 | return true;
15 | }
16 | catch (e)
17 | {
18 | console.error({lid: 1235}, e.message);
19 | }
20 |
21 | return false;
22 | };
23 |
24 | /**
25 | *
26 | * @returns {boolean}
27 | */
28 | const add20 = function ()
29 | {
30 | try
31 | {
32 |
33 | return true;
34 | }
35 | catch (e)
36 | {
37 | console.error({lid: 1235}, e.message);
38 | }
39 |
40 | return false;
41 | };
42 |
43 | /**
44 | *
45 | * @returns {boolean}
46 | */
47 | const add30 = function ()
48 | {
49 | try
50 | {
51 |
52 | return true;
53 | }
54 | catch (e)
55 | {
56 | console.error({lid: 1235}, e.message);
57 | }
58 |
59 | return false;
60 | };
61 |
62 | module.exports.add20 = add20;
63 | module.exports.add30 = add30;
64 |
65 | exports.ff001 = add10;
66 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-81.cjs:
--------------------------------------------------------------------------------
1 | const {
2 | AnyClass
3 | } = require('anylib');
4 |
5 |
6 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-9.cjs:
--------------------------------------------------------------------------------
1 | const rgbhex = require("rgb-hex-cjs");
2 |
3 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test-x.cjs:
--------------------------------------------------------------------------------
1 | const rgbhex = require("rgb-hex-cjs");
2 |
3 |
--------------------------------------------------------------------------------
/test/assets/given/demo-test.cjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
7 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
8 |
9 | QuickLog.setContexts(LOG_CONTEXT);
10 | QuickLog.setTargets(LOG_TARGETS);
11 |
12 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
13 |
14 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
15 |
16 |
17 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
18 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
19 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
20 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
21 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
22 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
23 | QuickLog.log(`Basic Log example 1`);
24 | QuickLog2.log(`Basic Log example 1`);
25 | QuickLog3.log(`Basic Log example 1`);
26 |
--------------------------------------------------------------------------------
/test/assets/given/file1.cjs:
--------------------------------------------------------------------------------
1 | class ClassA {
2 | }
3 | const ns1 = {
4 | ClassA
5 | }
6 | module.exports = {ns1};
--------------------------------------------------------------------------------
/test/assets/given/multi/demo-bad-syntax.cjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | var QuickLog4 = "rr";
7 |
8 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
9 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
10 |
11 | QuickLog4 = require("../../src/cjs/quick-log.cjs")
12 |
13 | let myLog1, QuickLog5, yourLog;
14 | let myLog2, QuickLog6, yourLog2;
15 | let QuickLog7, myLog2, yourLog2;
16 |
17 | QuickLog.setContexts(LOG_CONTEXT);
18 | QuickLog.setTargets(LOG_TARGETS);
19 |
20 | QuickLog5 = require("../../src/cjs/quick-log.cjs");
21 | QuickLog6 = require("../../src/cjs/quick-log.cjs")
22 | QuickLog7 = require("../../src/cjs/quick-log.cjs")
23 |
24 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
25 |
26 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
27 |
28 |
29 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
30 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
31 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
32 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
33 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
34 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
35 | QuickLog.log(`Basic Log example 1`);
36 | QuickLog2.log(`Basic Log example 1`);
37 | QuickLog3.log(`Basic Log example 1`);
38 |
--------------------------------------------------------------------------------
/test/assets/given/multi/demo-test-3.cjs:
--------------------------------------------------------------------------------
1 | /** const chalk001 = require("chalk-cjs"); **/
2 | const chalk000 = require("chalk-cjs"); // const path = require("path");
3 | // const chalk002 = require("chalk-cjs");
4 | const aa = "const chalk003 = require(\"chalk-cjs\");"
5 | const colorConvert = require("color-convert-cjs");
6 | const magnimus = require("mama-magnimus");
7 | const magnimus2 = require("mama-magnimus-cjs");
8 | const rgbhex = /** Cool **/ require("rgb-hex-cjs");
9 | const INFO1 = require("./dep-1.cjs");
10 | const INFO2 = require("./dep-2.cjs");
11 | const INFO3 = require('./dep-3.js');
12 | const bb = `
13 | const chalk004 = require("chalk-cjs");
14 |
15 | const chalk005 = require("chalk-cjs");
16 | `
17 | const INFO4 = require("./something.js");
18 | const INFO5 = require("./something.cjs");
19 | const path = require("path");
20 |
21 | /**
22 | * Multi line comment
23 | */
24 | const {DIRECTION, MESSAGE} = require("./dep-1");
25 |
26 | // ----
27 |
28 | /**
29 | * @class SomeClass
30 | */
31 | class SomeClass
32 | {
33 | constructor()
34 | {
35 | console.log(DIRECTION)
36 | console.log(MESSAGE)
37 | console.log(INFO1)
38 | }
39 | }
40 |
41 | module.exports = SomeClass;
--------------------------------------------------------------------------------
/test/assets/given/multi/demo-test-4.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | const SPECIAL_CONSTANTS = {
4 | WELCOME_CONTENT: "Welcome",
5 | };
6 |
7 | const SPECIAL_CONSTANTS_2 = {
8 | COMMAND_NOT_SENT : "COMMAND_NOT_SENT",
9 | };
10 |
11 | module.exports = {SPECIAL_CONSTANTS, SPECIAL_CONSTANTS_2};
--------------------------------------------------------------------------------
/test/assets/given/multi/demo-test-5.cjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | var QuickLog4 = "rr";
7 |
8 | let some1 = require("./demo-test-2.cjs");
9 | var some2 = require("./demo-test-3");
10 |
11 |
12 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
13 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
14 |
15 | QuickLog4 = require("../../src/cjs/quick-log.cjs")
16 |
17 | let myLog1, QuickLog5, yourLog;
18 | let myLog2, QuickLog6, yourLog2;
19 | let QuickLog7, yourLog2;
20 |
21 | QuickLog.setContexts(LOG_CONTEXT);
22 | QuickLog.setTargets(LOG_TARGETS);
23 |
24 | QuickLog5 = require("../../src/cjs/quick-log.cjs");
25 | QuickLog6 = require("../../src/cjs/quick-log.cjs")
26 | QuickLog7 = require("../../src/cjs/quick-log.cjs")
27 |
28 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
29 |
30 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
31 |
32 |
33 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
34 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
35 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
36 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
37 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
38 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
39 | QuickLog.log(`Basic Log example 1`);
40 | QuickLog2.log(`Basic Log example 1`);
41 | QuickLog3.log(`Basic Log example 1`);
42 |
--------------------------------------------------------------------------------
/test/assets/given/multi/demo-test.cjs:
--------------------------------------------------------------------------------
1 | let QuickLog;
2 | const {LOG_CONTEXT, LOG_TARGETS} = require("./contexts-def.cjs")
3 | QuickLog = require("../../src/cjs/quick-log.cjs");
4 | let QuickLog2 = require("../../src/cjs/quick-log.cjs");
5 | var QuickLog3 = require("../../src/cjs/quick-log.cjs");
6 | const cc = `var QuickLog3 = require("../../src/cjs/quick-log.cjs")`;
7 | // const aa = "let QuickLog2 = require(\"../../src/cjs/quick-log.cjs\")";
8 |
9 | QuickLog.setContexts(LOG_CONTEXT);
10 | QuickLog.setTargets(LOG_TARGETS);
11 |
12 | const {COLOR_TABLE, SYSTEM} = require("./constants.cjs");
13 |
14 | QuickLog.setFormat(({context, id, message})=>`${context}: (${id}) ${message}`);
15 |
16 |
17 | QuickLog.log(LOG_CONTEXT.STANDARD, `Basic Log example 2`, "+Something 0", "+Something 1");
18 | QuickLog.log({context: LOG_CONTEXT.TEST, lid: 1000}, `Test Log example`);
19 | QuickLog.log(LOG_CONTEXT.TEST, `Test Log example`, "+Something 3");
20 | QuickLog.log(LOG_CONTEXT.C1, `Test Log example C1`);
21 | QuickLog.log(LOG_CONTEXT.C2, `Test Log example C2`);
22 | QuickLog.log(LOG_CONTEXT.C3, `Test Log example C3`);
23 | QuickLog.log(`Basic Log example 1`);
24 | QuickLog2.log(`Basic Log example 1`);
25 | QuickLog3.log(`Basic Log example 1`);
26 |
--------------------------------------------------------------------------------
/test/assets/given/my-test-class-0.cjs:
--------------------------------------------------------------------------------
1 |
2 | class MyTestClass
3 | {
4 | constructor()
5 | {
6 |
7 | }
8 |
9 | someMethod()
10 | {
11 | console.log(`Some method was called`)
12 | }
13 | }
14 |
15 | module.exports = MyTestClass;
--------------------------------------------------------------------------------
/test/assets/given/my-test-class.cjs:
--------------------------------------------------------------------------------
1 |
2 | class MyTestClass
3 | {
4 | constructor()
5 | {
6 |
7 | }
8 |
9 | someMethod()
10 | {
11 | console.log(`Some method was called`)
12 | }
13 | }
14 |
15 | module.exports = MyTestClass;
--------------------------------------------------------------------------------
/test/assets/given/package-json/package-1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "version": "1.0.2",
4 | "random": 123456,
5 | "main": "./example/demo-test-xx.cjs",
6 | "module": "./actual/demo-test-xx.mjs",
7 | "type": "module",
8 | "exports": {
9 | "require": "./given/xx.cjs",
10 | "import": "./actual/xx.mjs"
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/given/package-json/package-2.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "main": "./given/demo-test-xx.cjs",
4 | "module": "./actual/demo-test-xx.mjs",
5 | "type": "module",
6 | "exports": {
7 | ".": {
8 | "require": "./given/demo-test-xx.cjs",
9 | "import": "./actual/demo-test-xx.mjs"
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/given/package-json/package-3.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "main": "./example/cjs/demo.cjs",
4 | "module": "./generated/esm/demo.mjs",
5 | "type": "commonjs",
6 | "exports": {
7 | ".": {
8 | "require": "somewhere"
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/test/assets/given/package-json/package-4.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "something",
3 | "version": "1.0.2",
4 | "random": 123456,
5 | "main": "./example/demo-test-xx.cjs",
6 | "module": "./actual/demo-test-xx.mjs",
7 | "type": "module"
8 | }
--------------------------------------------------------------------------------
/test/assets/given/package-json/package-cases.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test",
3 | "version": "1.0.0",
4 | "dependencies": {
5 | "commondir": "^1.0.1",
6 | "flatted": "^3.2.5",
7 | "rgb-hex": "^4.0.0",
8 | "rgb-hex-cjs": "npm:rgb-hex@^3.0.0",
9 | "to-ansi": "^1.4.3",
10 | "window-size": "^1.1.1"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/assets/given/set-output-extension/demo-test-82.js:
--------------------------------------------------------------------------------
1 | const test2 = require("./test2.js");
2 |
3 | test2.doIt();
4 |
5 |
6 | // test2.js
7 |
8 | module.exports = {
9 | doIt: () => {
10 | console.log("hello")
11 | }
12 | }
--------------------------------------------------------------------------------
/test/assets/given/set-output-extension/test2.js:
--------------------------------------------------------------------------------
1 | const a = "hello world";
2 |
3 | module.exports.a = a;
4 |
--------------------------------------------------------------------------------
/test/assets/index-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/test/assets/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/test/assets/other.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Title
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/node_modules/.bin/window-size:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 |
4 | case `uname` in
5 | *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 | esac
7 |
8 | if [ -x "$basedir/node" ]; then
9 | exec "$basedir/node" "$basedir/../window-size/cli.js" "$@"
10 | else
11 | exec node "$basedir/../window-size/cli.js" "$@"
12 | fi
13 |
--------------------------------------------------------------------------------
/test/node_modules/.bin/window-size.cmd:
--------------------------------------------------------------------------------
1 | @ECHO off
2 | GOTO start
3 | :find_dp0
4 | SET dp0=%~dp0
5 | EXIT /b
6 | :start
7 | SETLOCAL
8 | CALL :find_dp0
9 |
10 | IF EXIST "%dp0%\node.exe" (
11 | SET "_prog=%dp0%\node.exe"
12 | ) ELSE (
13 | SET "_prog=node"
14 | SET PATHEXT=%PATHEXT:;.JS;=;%
15 | )
16 |
17 | endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\window-size\cli.js" %*
18 |
--------------------------------------------------------------------------------
/test/node_modules/.bin/window-size.ps1:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env pwsh
2 | $basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 |
4 | $exe=""
5 | if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 | # Fix case when both the Windows and Linux builds of Node
7 | # are installed in the same directory
8 | $exe=".exe"
9 | }
10 | $ret=0
11 | if (Test-Path "$basedir/node$exe") {
12 | # Support pipeline input
13 | if ($MyInvocation.ExpectingInput) {
14 | $input | & "$basedir/node$exe" "$basedir/../window-size/cli.js" $args
15 | } else {
16 | & "$basedir/node$exe" "$basedir/../window-size/cli.js" $args
17 | }
18 | $ret=$LASTEXITCODE
19 | } else {
20 | # Support pipeline input
21 | if ($MyInvocation.ExpectingInput) {
22 | $input | & "node$exe" "$basedir/../window-size/cli.js" $args
23 | } else {
24 | & "node$exe" "$basedir/../window-size/cli.js" $args
25 | }
26 | $ret=$LASTEXITCODE
27 | }
28 | exit $ret
29 |
--------------------------------------------------------------------------------
/test/node_modules/commondir/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2013 James Halliday (mail@substack.net)
4 |
5 | Permission is hereby granted, free of charge,
6 | to any person obtaining a copy of this software and
7 | associated documentation files (the "Software"), to
8 | deal in the Software without restriction, including
9 | without limitation the rights to use, copy, modify,
10 | merge, publish, distribute, sublicense, and/or sell
11 | copies of the Software, and to permit persons to whom
12 | the Software is furnished to do so,
13 | subject to the following conditions:
14 |
15 | The above copyright notice and this permission notice
16 | shall be included in all copies or substantial portions of the Software.
17 |
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/test/node_modules/commondir/example/dir.js:
--------------------------------------------------------------------------------
1 | var commondir = require('../');
2 | var dir = commondir(process.argv.slice(2));
3 | console.log(dir);
4 |
--------------------------------------------------------------------------------
/test/node_modules/commondir/index.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 |
3 | module.exports = function (basedir, relfiles) {
4 | if (relfiles) {
5 | var files = relfiles.map(function (r) {
6 | return path.resolve(basedir, r);
7 | });
8 | }
9 | else {
10 | var files = basedir;
11 | }
12 |
13 | var res = files.slice(1).reduce(function (ps, file) {
14 | if (!file.match(/^([A-Za-z]:)?\/|\\/)) {
15 | throw new Error('relative path without a basedir');
16 | }
17 |
18 | var xs = file.split(/\/+|\\+/);
19 | for (
20 | var i = 0;
21 | ps[i] === xs[i] && i < Math.min(ps.length, xs.length);
22 | i++
23 | );
24 | return ps.slice(0, i);
25 | }, files[0].split(/\/+|\\+/));
26 |
27 | // Windows correctly handles paths with forward-slashes
28 | return res.length > 1 ? res.join('/') : '/'
29 | };
30 |
--------------------------------------------------------------------------------
/test/node_modules/commondir/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "commondir",
3 | "version": "1.0.1",
4 | "description": "compute the closest common parent for file paths",
5 | "main": "index.js",
6 | "dependencies": {},
7 | "devDependencies": {
8 | "tape": "^3.5.0"
9 | },
10 | "scripts": {
11 | "test": "tape test/*.js"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "http://github.com/substack/node-commondir.git"
16 | },
17 | "keywords": [
18 | "common",
19 | "path",
20 | "directory",
21 | "file",
22 | "parent",
23 | "root"
24 | ],
25 | "author": {
26 | "name": "James Halliday",
27 | "email": "mail@substack.net",
28 | "url": "http://substack.net"
29 | },
30 | "license": "MIT",
31 | "engine": {
32 | "node": ">=0.4"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/test/node_modules/commondir/readme.markdown:
--------------------------------------------------------------------------------
1 | # commondir
2 |
3 | compute the closest common parent directory among an array of directories
4 |
5 | # example
6 |
7 | ``` js
8 | var commondir = require('commondir');
9 | var dir = commondir(process.argv.slice(2))
10 | console.log(dir);
11 | ```
12 |
13 | output:
14 |
15 | ```
16 | $ node dir.js /x/y/z /x/y /x/y/w/q
17 | /x/y
18 | $ node ../baz ../../foo/quux ./bizzy
19 | /foo
20 | ```
21 |
22 | # methods
23 |
24 | ``` js
25 | var commondir = require('commondir');
26 | ```
27 |
28 | ## commondir(absolutePaths)
29 |
30 | Compute the closest common parent directory for an array `absolutePaths`.
31 |
32 | ## commondir(basedir, relativePaths)
33 |
34 | Compute the closest common parent directory for an array `relativePaths` which
35 | will be resolved for each `dir` in `relativePaths` according to:
36 | `path.resolve(basedir, dir)`.
37 |
38 | # install
39 |
40 | With [npm](https://npmjs.org) do:
41 |
42 | ```
43 | npm install commondir
44 | ```
45 |
46 | # license
47 |
48 | MIT
49 |
--------------------------------------------------------------------------------
/test/node_modules/commondir/test/dirs.js:
--------------------------------------------------------------------------------
1 | var test = require('tape');
2 | var commondir = require('../');
3 |
4 | test('common', function (t) {
5 | t.equal(
6 | commondir([ '/foo', '//foo/bar', '/foo//bar/baz' ]),
7 | '/foo'
8 | );
9 | t.equal(
10 | commondir([ '/a/b/c', '/a/b', '/a/b/c/d/e' ]),
11 | '/a/b'
12 | );
13 | t.equal(
14 | commondir([ '/x/y/z/w', '/xy/z', '/x/y/z' ]),
15 | '/'
16 | );
17 | t.equal(
18 | commondir([ 'X:\\foo', 'X:\\\\foo\\bar', 'X://foo/bar/baz' ]),
19 | 'X:/foo'
20 | );
21 | t.equal(
22 | commondir([ 'X:\\a\\b\\c', 'X:\\a\\b', 'X:\\a\\b\\c\\d\\e' ]),
23 | 'X:/a/b'
24 | );
25 | t.equal(
26 | commondir([ 'X:\\x\\y\\z\\w', '\\\\xy\\z', '\\x\\y\\z' ]),
27 | '/'
28 | );
29 | t.throws(function () {
30 | commondir([ '/x/y/z/w', 'qrs', '/x/y/z' ]);
31 | });
32 | t.end();
33 | });
34 |
35 | test('base', function (t) {
36 | t.equal(
37 | commondir('/foo/bar', [ 'baz', './quux', '../bar/bazzy' ]),
38 | '/foo/bar'
39 | );
40 | t.equal(
41 | commondir('/a/b', [ 'c', '../b/.', '../../a/b/e' ]),
42 | '/a/b'
43 | );
44 | t.equal(
45 | commondir('/a/b/c', [ '..', '../d', '../../a/z/e' ]),
46 | '/a'
47 | );
48 | t.equal(
49 | commondir('/foo/bar', [ 'baz', '.\\quux', '..\\bar\\bazzy' ]),
50 | '/foo/bar'
51 | );
52 | // Tests including X:\ basedirs must wait until path.resolve supports
53 | // Windows-style paths, starting in Node.js v0.5.X
54 | t.end();
55 | });
56 |
--------------------------------------------------------------------------------
/test/node_modules/define-property/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015, 2017, Jon Schlinkert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/define-property/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * define-property
3 | *
4 | * Copyright (c) 2015, 2017, Jon Schlinkert.
5 | * Released under the MIT License.
6 | */
7 |
8 | 'use strict';
9 |
10 | var isDescriptor = require('is-descriptor');
11 |
12 | module.exports = function defineProperty(obj, prop, val) {
13 | if (typeof obj !== 'object' && typeof obj !== 'function') {
14 | throw new TypeError('expected an object or function.');
15 | }
16 |
17 | if (typeof prop !== 'string') {
18 | throw new TypeError('expected `prop` to be a string.');
19 | }
20 |
21 | if (isDescriptor(val) && ('set' in val || 'get' in val)) {
22 | return Object.defineProperty(obj, prop, val);
23 | }
24 |
25 | return Object.defineProperty(obj, prop, {
26 | configurable: true,
27 | enumerable: false,
28 | writable: true,
29 | value: val
30 | });
31 | };
32 |
--------------------------------------------------------------------------------
/test/node_modules/define-property/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "define-property",
3 | "description": "Define a non-enumerable property on an object.",
4 | "version": "1.0.0",
5 | "homepage": "https://github.com/jonschlinkert/define-property",
6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7 | "repository": "jonschlinkert/define-property",
8 | "bugs": {
9 | "url": "https://github.com/jonschlinkert/define-property/issues"
10 | },
11 | "license": "MIT",
12 | "files": [
13 | "index.js"
14 | ],
15 | "main": "index.js",
16 | "engines": {
17 | "node": ">=0.10.0"
18 | },
19 | "scripts": {
20 | "test": "mocha"
21 | },
22 | "dependencies": {
23 | "is-descriptor": "^1.0.0"
24 | },
25 | "devDependencies": {
26 | "gulp-format-md": "^0.1.12",
27 | "mocha": "^3.2.0"
28 | },
29 | "keywords": [
30 | "define",
31 | "define-property",
32 | "enumerable",
33 | "key",
34 | "non",
35 | "non-enumerable",
36 | "object",
37 | "prop",
38 | "property",
39 | "value"
40 | ],
41 | "verb": {
42 | "related": {
43 | "list": [
44 | "extend-shallow",
45 | "merge-deep",
46 | "assign-deep",
47 | "mixin-deep"
48 | ]
49 | },
50 | "toc": false,
51 | "layout": "default",
52 | "tasks": [
53 | "readme"
54 | ],
55 | "plugins": [
56 | "gulp-format-md"
57 | ],
58 | "lint": {
59 | "reflinks": true
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/test/node_modules/flatted/LICENSE:
--------------------------------------------------------------------------------
1 | ISC License
2 |
3 | Copyright (c) 2018-2020, Andrea Giammarchi, @WebReflection
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted, provided that the above
7 | copyright notice and this permission notice appear in all copies.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 | PERFORMANCE OF THIS SOFTWARE.
16 |
--------------------------------------------------------------------------------
/test/node_modules/flatted/cjs/package.json:
--------------------------------------------------------------------------------
1 | {"type":"commonjs"}
--------------------------------------------------------------------------------
/test/node_modules/flatted/es.js:
--------------------------------------------------------------------------------
1 | self.Flatted=function(t){"use strict";
2 | /*! (c) 2020 Andrea Giammarchi */const{parse:e,stringify:n}=JSON,{keys:r}=Object,s=String,o="string",c={},l="object",a=(t,e)=>e,f=t=>t instanceof s?s(t):t,i=(t,e)=>typeof e===o?new s(e):e,u=(t,e,n,o)=>{const a=[];for(let f=r(n),{length:i}=f,u=0;u{const r=s(e.push(n)-1);return t.set(n,r),r},y=(t,n)=>{const r=e(t,i).map(f),s=r[0],o=n||a,c=typeof s===l&&s?u(r,new Set,s,o):s;return o.call({"":c},"",c)},g=(t,e,r)=>{const s=e&&typeof e===l?(t,n)=>""===t||-1y(n(t)),t.parse=y,t.stringify=g,t.toJSON=t=>e(g(t)),t}({});
3 |
--------------------------------------------------------------------------------
/test/node_modules/flatted/esm.js:
--------------------------------------------------------------------------------
1 | /*! (c) 2020 Andrea Giammarchi */
2 | const{parse:t,stringify:e}=JSON,{keys:n}=Object,o=String,c={},r=(t,e)=>e,s=t=>t instanceof o?o(t):t,l=(t,e)=>"string"==typeof e?new o(e):e,a=(t,e,r,s)=>{const l=[];for(let a=n(r),{length:f}=a,i=0;i{const c=o(e.push(n)-1);return t.set(n,c),c},i=(e,n)=>{const o=t(e,l).map(s),c=o[0],f=n||r,i="object"==typeof c&&c?a(o,new Set,c,f):c;return f.call({"":i},"",i)},p=(t,n,o)=>{const c=n&&"object"==typeof n?(t,e)=>""===t||-1t(p(e)),g=t=>i(e(t));export{g as fromJSON,i as parse,p as stringify,u as toJSON};
3 |
--------------------------------------------------------------------------------
/test/node_modules/flatted/min.js:
--------------------------------------------------------------------------------
1 | self.Flatted=function(n){"use strict";
2 | /*! (c) 2020 Andrea Giammarchi */var t=JSON.parse,r=JSON.stringify,e=Object.keys,u=String,a="string",f={},i="object",o=function(n,t){return t},c=function(n){return n instanceof u?u(n):n},l=function(n,t){return typeof t===a?new u(t):t},s=function n(t,r,a,o){for(var c=[],l=e(a),s=l.length,p=0;p
3 | *
4 | * Copyright (c) 2015-2017, Jon Schlinkert.
5 | * Released under the MIT License.
6 | */
7 |
8 | 'use strict';
9 |
10 | var typeOf = require('kind-of');
11 |
12 | // accessor descriptor properties
13 | var accessor = {
14 | get: 'function',
15 | set: 'function',
16 | configurable: 'boolean',
17 | enumerable: 'boolean'
18 | };
19 |
20 | function isAccessorDescriptor(obj, prop) {
21 | if (typeof prop === 'string') {
22 | var val = Object.getOwnPropertyDescriptor(obj, prop);
23 | return typeof val !== 'undefined';
24 | }
25 |
26 | if (typeOf(obj) !== 'object') {
27 | return false;
28 | }
29 |
30 | if (has(obj, 'value') || has(obj, 'writable')) {
31 | return false;
32 | }
33 |
34 | if (!has(obj, 'get') || typeof obj.get !== 'function') {
35 | return false;
36 | }
37 |
38 | // tldr: it's valid to have "set" be undefined
39 | // "set" might be undefined if `Object.getOwnPropertyDescriptor`
40 | // was used to get the value, and only `get` was defined by the user
41 | if (has(obj, 'set') && typeof obj[key] !== 'function' && typeof obj[key] !== 'undefined') {
42 | return false;
43 | }
44 |
45 | for (var key in obj) {
46 | if (!accessor.hasOwnProperty(key)) {
47 | continue;
48 | }
49 |
50 | if (typeOf(obj[key]) === accessor[key]) {
51 | continue;
52 | }
53 |
54 | if (typeof obj[key] !== 'undefined') {
55 | return false;
56 | }
57 | }
58 | return true;
59 | }
60 |
61 | function has(obj, key) {
62 | return {}.hasOwnProperty.call(obj, key);
63 | }
64 |
65 | /**
66 | * Expose `isAccessorDescriptor`
67 | */
68 |
69 | module.exports = isAccessorDescriptor;
70 |
--------------------------------------------------------------------------------
/test/node_modules/is-buffer/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Feross Aboukhadijeh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/is-buffer/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Determine if an object is a Buffer
3 | *
4 | * @author Feross Aboukhadijeh
5 | * @license MIT
6 | */
7 |
8 | // The _isBuffer check is for Safari 5-7 support, because it's missing
9 | // Object.prototype.constructor. Remove this eventually
10 | module.exports = function (obj) {
11 | return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
12 | }
13 |
14 | function isBuffer (obj) {
15 | return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
16 | }
17 |
18 | // For Node v0.10 support. Remove this eventually.
19 | function isSlowBuffer (obj) {
20 | return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
21 | }
22 |
--------------------------------------------------------------------------------
/test/node_modules/is-buffer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "is-buffer",
3 | "description": "Determine if an object is a Buffer",
4 | "version": "1.1.6",
5 | "author": {
6 | "name": "Feross Aboukhadijeh",
7 | "email": "feross@feross.org",
8 | "url": "http://feross.org/"
9 | },
10 | "bugs": {
11 | "url": "https://github.com/feross/is-buffer/issues"
12 | },
13 | "dependencies": {},
14 | "devDependencies": {
15 | "standard": "*",
16 | "tape": "^4.0.0",
17 | "zuul": "^3.0.0"
18 | },
19 | "keywords": [
20 | "buffer",
21 | "buffers",
22 | "type",
23 | "core buffer",
24 | "browser buffer",
25 | "browserify",
26 | "typed array",
27 | "uint32array",
28 | "int16array",
29 | "int32array",
30 | "float32array",
31 | "float64array",
32 | "browser",
33 | "arraybuffer",
34 | "dataview"
35 | ],
36 | "license": "MIT",
37 | "main": "index.js",
38 | "repository": {
39 | "type": "git",
40 | "url": "git://github.com/feross/is-buffer.git"
41 | },
42 | "scripts": {
43 | "test": "standard && npm run test-node && npm run test-browser",
44 | "test-browser": "zuul -- test/*.js",
45 | "test-browser-local": "zuul --local -- test/*.js",
46 | "test-node": "tape test/*.js"
47 | },
48 | "testling": {
49 | "files": "test/*.js"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/test/node_modules/is-buffer/test/basic.js:
--------------------------------------------------------------------------------
1 | var isBuffer = require('../')
2 | var test = require('tape')
3 |
4 | test('is-buffer', function (t) {
5 | t.equal(isBuffer(Buffer.alloc(4)), true, 'new Buffer(4)')
6 | t.equal(isBuffer(Buffer.allocUnsafeSlow(100)), true, 'SlowBuffer(100)')
7 |
8 | t.equal(isBuffer(undefined), false, 'undefined')
9 | t.equal(isBuffer(null), false, 'null')
10 | t.equal(isBuffer(''), false, 'empty string')
11 | t.equal(isBuffer(true), false, 'true')
12 | t.equal(isBuffer(false), false, 'false')
13 | t.equal(isBuffer(0), false, '0')
14 | t.equal(isBuffer(1), false, '1')
15 | t.equal(isBuffer(1.0), false, '1.0')
16 | t.equal(isBuffer('string'), false, 'string')
17 | t.equal(isBuffer({}), false, '{}')
18 | t.equal(isBuffer([]), false, '[]')
19 | t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
20 | t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
21 | t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
22 |
23 | t.end()
24 | })
25 |
--------------------------------------------------------------------------------
/test/node_modules/is-data-descriptor/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2017, Jon Schlinkert.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/is-data-descriptor/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * is-data-descriptor
3 | *
4 | * Copyright (c) 2015-2017, Jon Schlinkert.
5 | * Released under the MIT License.
6 | */
7 |
8 | 'use strict';
9 |
10 | var typeOf = require('kind-of');
11 |
12 | module.exports = function isDataDescriptor(obj, prop) {
13 | // data descriptor properties
14 | var data = {
15 | configurable: 'boolean',
16 | enumerable: 'boolean',
17 | writable: 'boolean'
18 | };
19 |
20 | if (typeOf(obj) !== 'object') {
21 | return false;
22 | }
23 |
24 | if (typeof prop === 'string') {
25 | var val = Object.getOwnPropertyDescriptor(obj, prop);
26 | return typeof val !== 'undefined';
27 | }
28 |
29 | if (!('value' in obj) && !('writable' in obj)) {
30 | return false;
31 | }
32 |
33 | for (var key in obj) {
34 | if (key === 'value') continue;
35 |
36 | if (!data.hasOwnProperty(key)) {
37 | continue;
38 | }
39 |
40 | if (typeOf(obj[key]) === data[key]) {
41 | continue;
42 | }
43 |
44 | if (typeof obj[key] !== 'undefined') {
45 | return false;
46 | }
47 | }
48 | return true;
49 | };
50 |
--------------------------------------------------------------------------------
/test/node_modules/is-data-descriptor/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "is-data-descriptor",
3 | "description": "Returns true if a value has the characteristics of a valid JavaScript data descriptor.",
4 | "version": "1.0.0",
5 | "homepage": "https://github.com/jonschlinkert/is-data-descriptor",
6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7 | "contributors": [
8 | "Jon Schlinkert (http://twitter.com/jonschlinkert)",
9 | "Rouven Weßling (www.rouvenwessling.de)"
10 | ],
11 | "repository": "jonschlinkert/is-data-descriptor",
12 | "bugs": {
13 | "url": "https://github.com/jonschlinkert/is-data-descriptor/issues"
14 | },
15 | "license": "MIT",
16 | "files": [
17 | "index.js"
18 | ],
19 | "main": "index.js",
20 | "engines": {
21 | "node": ">=0.10.0"
22 | },
23 | "scripts": {
24 | "test": "mocha"
25 | },
26 | "dependencies": {
27 | "kind-of": "^6.0.0"
28 | },
29 | "devDependencies": {
30 | "gulp-format-md": "^1.0.0",
31 | "mocha": "^3.5.3"
32 | },
33 | "keywords": [
34 | "accessor",
35 | "check",
36 | "data",
37 | "descriptor",
38 | "get",
39 | "getter",
40 | "is",
41 | "keys",
42 | "object",
43 | "properties",
44 | "property",
45 | "set",
46 | "setter",
47 | "type",
48 | "valid",
49 | "value"
50 | ],
51 | "verb": {
52 | "toc": false,
53 | "layout": "default",
54 | "tasks": [
55 | "readme"
56 | ],
57 | "plugins": [
58 | "gulp-format-md"
59 | ],
60 | "related": {
61 | "list": [
62 | "is-accessor-descriptor",
63 | "is-data-descriptor",
64 | "is-descriptor",
65 | "isobject"
66 | ]
67 | },
68 | "lint": {
69 | "reflinks": true
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/test/node_modules/is-descriptor/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2017, Jon Schlinkert.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/test/node_modules/is-descriptor/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * is-descriptor
3 | *
4 | * Copyright (c) 2015-2017, Jon Schlinkert.
5 | * Released under the MIT License.
6 | */
7 |
8 | 'use strict';
9 |
10 | var typeOf = require('kind-of');
11 | var isAccessor = require('is-accessor-descriptor');
12 | var isData = require('is-data-descriptor');
13 |
14 | module.exports = function isDescriptor(obj, key) {
15 | if (typeOf(obj) !== 'object') {
16 | return false;
17 | }
18 | if ('get' in obj) {
19 | return isAccessor(obj, key);
20 | }
21 | return isData(obj, key);
22 | };
23 |
--------------------------------------------------------------------------------
/test/node_modules/is-number/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2016, Jon Schlinkert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/is-number/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * is-number
3 | *
4 | * Copyright (c) 2014-2015, Jon Schlinkert.
5 | * Licensed under the MIT License.
6 | */
7 |
8 | 'use strict';
9 |
10 | var typeOf = require('kind-of');
11 |
12 | module.exports = function isNumber(num) {
13 | var type = typeOf(num);
14 |
15 | if (type === 'string') {
16 | if (!num.trim()) return false;
17 | } else if (type !== 'number') {
18 | return false;
19 | }
20 |
21 | return (num - num + 1) >= 0;
22 | };
23 |
--------------------------------------------------------------------------------
/test/node_modules/is-number/node_modules/kind-of/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2017, Jon Schlinkert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/kind-of/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2017, Jon Schlinkert.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex-cjs/index.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | Convert RGB(A) color to HEX.
3 |
4 | @example
5 | ```
6 | import rgbHex = require('rgb-hex');
7 |
8 | rgbHex(65, 131, 196);
9 | //=> '4183c4'
10 |
11 | rgbHex('rgb(40, 42, 54)');
12 | //=> '282a36'
13 |
14 | rgbHex(65, 131, 196, 0.2);
15 | //=> '4183c433'
16 |
17 | rgbHex(40, 42, 54, '75%');
18 | //=> '282a36bf'
19 |
20 | rgbHex('rgba(40, 42, 54, 75%)');
21 | //=> '282a36bf'
22 | ```
23 | */
24 | declare function rgbHex(rgba: string): string;
25 | declare function rgbHex(red: number, green: number, blue: number, alpha?: string | number): string;
26 |
27 | export = rgbHex;
28 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex-cjs/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | /* eslint-disable no-mixed-operators */
3 | module.exports = (red, green, blue, alpha) => {
4 | const isPercent = (red + (alpha || '')).toString().includes('%');
5 |
6 | if (typeof red === 'string') {
7 | [red, green, blue, alpha] = red.match(/(0?\.?\d{1,3})%?\b/g).map(Number);
8 | } else if (alpha !== undefined) {
9 | alpha = parseFloat(alpha);
10 | }
11 |
12 | if (typeof red !== 'number' ||
13 | typeof green !== 'number' ||
14 | typeof blue !== 'number' ||
15 | red > 255 ||
16 | green > 255 ||
17 | blue > 255
18 | ) {
19 | throw new TypeError('Expected three numbers below 256');
20 | }
21 |
22 | if (typeof alpha === 'number') {
23 | if (!isPercent && alpha >= 0 && alpha <= 1) {
24 | alpha = Math.round(255 * alpha);
25 | } else if (isPercent && alpha >= 0 && alpha <= 100) {
26 | alpha = Math.round(255 * alpha / 100);
27 | } else {
28 | throw new TypeError(`Expected alpha value (${alpha}) as a fraction or percentage`);
29 | }
30 |
31 | alpha = (alpha | 1 << 8).toString(16).slice(1);
32 | } else {
33 | alpha = '';
34 | }
35 |
36 | return ((blue | green << 8 | red << 16) | 1 << 24).toString(16).slice(1) + alpha;
37 | };
38 | /* eslint-enable no-mixed-operators */
39 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex-cjs/license:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Sindre Sorhus (sindresorhus.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex-cjs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rgb-hex",
3 | "version": "3.0.0",
4 | "description": "Convert RGB(A) color to HEX",
5 | "license": "MIT",
6 | "repository": "sindresorhus/rgb-hex",
7 | "author": {
8 | "name": "Sindre Sorhus",
9 | "email": "sindresorhus@gmail.com",
10 | "url": "sindresorhus.com"
11 | },
12 | "engines": {
13 | "node": ">=8"
14 | },
15 | "scripts": {
16 | "test": "xo && ava && tsd"
17 | },
18 | "files": [
19 | "index.js",
20 | "index.d.ts"
21 | ],
22 | "keywords": [
23 | "rgb",
24 | "hex",
25 | "color",
26 | "colour",
27 | "convert",
28 | "conversion",
29 | "converter"
30 | ],
31 | "devDependencies": {
32 | "ava": "^1.4.1",
33 | "tsd": "^0.7.2",
34 | "xo": "^0.24.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex-cjs/readme.md:
--------------------------------------------------------------------------------
1 | # rgb-hex [](https://travis-ci.org/sindresorhus/rgb-hex)
2 |
3 | > Convert RGB(A) color to HEX
4 |
5 |
6 | ## Install
7 |
8 | ```
9 | $ npm install rgb-hex
10 | ```
11 |
12 |
13 | ## Usage
14 |
15 | ```js
16 | const rgbHex = require('rgb-hex');
17 |
18 | rgbHex(65, 131, 196);
19 | //=> '4183c4'
20 |
21 | rgbHex('rgb(40, 42, 54)');
22 | //=> '282a36'
23 |
24 | rgbHex(65, 131, 196, 0.2);
25 | //=> '4183c433'
26 |
27 | rgbHex(40, 42, 54, '75%');
28 | //=> '282a36bf'
29 |
30 | rgbHex('rgba(40, 42, 54, 75%)');
31 | //=> '282a36bf'
32 | ```
33 |
34 |
35 | ## Related
36 |
37 | - [rgb-hex-cli](https://github.com/sindresorhus/rgb-hex-cli) - CLI for this module
38 | - [hex-rgb](https://github.com/sindresorhus/hex-rgb) - Convert HEX color to RGB
39 |
40 |
41 | ## License
42 |
43 | MIT © [Sindre Sorhus](https://sindresorhus.com)
44 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex/index.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | Convert RGB(A) color to HEX.
3 |
4 | @example
5 | ```
6 | import rgbHex from 'rgb-hex';
7 |
8 | rgbHex(65, 131, 196);
9 | //=> '4183c4'
10 |
11 | rgbHex('rgb(40, 42, 54)');
12 | //=> '282a36'
13 |
14 | rgbHex(65, 131, 196, 0.2);
15 | //=> '4183c433'
16 |
17 | rgbHex(40, 42, 54, '75%');
18 | //=> '282a36bf'
19 |
20 | rgbHex('rgba(40, 42, 54, 75%)');
21 | //=> '282a36bf'
22 | ```
23 | */
24 | export default function rgbHex(rgba: string): string;
25 | export default function rgbHex(red: number, green: number, blue: number, alpha?: string | number): string; // eslint-disable-line no-redeclare
26 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex/index.js:
--------------------------------------------------------------------------------
1 | export default function rgbHex(red, green, blue, alpha) {
2 | const isPercent = (red + (alpha || '')).toString().includes('%');
3 |
4 | if (typeof red === 'string') {
5 | [red, green, blue, alpha] = red.match(/(0?\.?\d{1,3})%?\b/g).map(component => Number(component));
6 | } else if (alpha !== undefined) {
7 | alpha = Number.parseFloat(alpha);
8 | }
9 |
10 | if (typeof red !== 'number' ||
11 | typeof green !== 'number' ||
12 | typeof blue !== 'number' ||
13 | red > 255 ||
14 | green > 255 ||
15 | blue > 255
16 | ) {
17 | throw new TypeError('Expected three numbers below 256');
18 | }
19 |
20 | if (typeof alpha === 'number') {
21 | if (!isPercent && alpha >= 0 && alpha <= 1) {
22 | alpha = Math.round(255 * alpha);
23 | } else if (isPercent && alpha >= 0 && alpha <= 100) {
24 | alpha = Math.round(255 * alpha / 100);
25 | } else {
26 | throw new TypeError(`Expected alpha value (${alpha}) as a fraction or percentage`);
27 | }
28 |
29 | alpha = (alpha | 1 << 8).toString(16).slice(1); // eslint-disable-line no-mixed-operators
30 | } else {
31 | alpha = '';
32 | }
33 |
34 | // TODO: Remove this ignore comment.
35 | // eslint-disable-next-line no-mixed-operators
36 | return ((blue | green << 8 | red << 16) | 1 << 24).toString(16).slice(1) + alpha;
37 | }
38 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex/license:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rgb-hex",
3 | "version": "4.0.0",
4 | "description": "Convert RGB(A) color to HEX",
5 | "license": "MIT",
6 | "repository": "sindresorhus/rgb-hex",
7 | "funding": "https://github.com/sponsors/sindresorhus",
8 | "author": {
9 | "name": "Sindre Sorhus",
10 | "email": "sindresorhus@gmail.com",
11 | "url": "https://sindresorhus.com"
12 | },
13 | "type": "module",
14 | "exports": "./index.js",
15 | "engines": {
16 | "node": ">=12"
17 | },
18 | "scripts": {
19 | "test": "xo && ava && tsd"
20 | },
21 | "files": [
22 | "index.js",
23 | "index.d.ts"
24 | ],
25 | "keywords": [
26 | "rgb",
27 | "hex",
28 | "color",
29 | "colour",
30 | "convert",
31 | "conversion",
32 | "converter"
33 | ],
34 | "devDependencies": {
35 | "ava": "^3.15.0",
36 | "tsd": "^0.14.0",
37 | "xo": "^0.39.1"
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/test/node_modules/rgb-hex/readme.md:
--------------------------------------------------------------------------------
1 | # rgb-hex
2 |
3 | > Convert RGB(A) color to HEX
4 |
5 | ## Install
6 |
7 | ```
8 | $ npm install rgb-hex
9 | ```
10 |
11 | ## Usage
12 |
13 | ```js
14 | import rgbHex from 'rgb-hex';
15 |
16 | rgbHex(65, 131, 196);
17 | //=> '4183c4'
18 |
19 | rgbHex('rgb(40, 42, 54)');
20 | //=> '282a36'
21 |
22 | rgbHex(65, 131, 196, 0.2);
23 | //=> '4183c433'
24 |
25 | rgbHex(40, 42, 54, '75%');
26 | //=> '282a36bf'
27 |
28 | rgbHex('rgba(40, 42, 54, 75%)');
29 | //=> '282a36bf'
30 | ```
31 |
32 | ## Related
33 |
34 | - [rgb-hex-cli](https://github.com/sindresorhus/rgb-hex-cli) - CLI for this module
35 | - [hex-rgb](https://github.com/sindresorhus/hex-rgb) - Convert HEX color to RGB
36 |
--------------------------------------------------------------------------------
/test/node_modules/to-ansi/.to-esm.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | replaceStart: [
3 | {
4 | search : "const ansiEscapes = require(\"ansi-escapes-cjs\");",
5 | replace: "// *** ansiEscapes ***"
6 | }],
7 | replaceEnd: [
8 | {
9 | search : "// *** ansiEscapes ***",
10 | replace: "import ansiEscapes from \"ansi-escapes\";"
11 | }
12 | ],
13 | }
--------------------------------------------------------------------------------
/test/node_modules/to-ansi/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.4.3](https://github.com/thimpat/to-ansi/compare/v1.4.2...v1.4.3) (2022-04-28)
2 |
3 | ## [1.4.2](https://github.com/thimpat/to-ansi/compare/v1.4.1...v1.4.2) (2022-04-28)
4 |
5 | ## [1.4.1](https://github.com/thimpat/to-ansi/compare/v1.4.0...v1.4.1) (2022-04-28)
6 |
7 | # [1.4.0](https://github.com/thimpat/to-ansi/compare/v1.3.1...v1.4.0) (2022-04-28)
8 |
9 | ## [1.3.1](https://github.com/thimpat/to-ansi/compare/v1.3.0...v1.3.1) (2022-04-27)
10 |
11 | # [1.3.0](https://github.com/thimpat/to-ansi/compare/v1.2.1...v1.3.0) (2022-04-27)
12 |
13 | ## [1.2.1](https://github.com/thimpat/to-ansi/compare/v1.2.0...v1.2.1) (2022-04-23)
14 |
15 | # [1.2.0](https://github.com/thimpat/to-ansi/compare/v1.1.2...v1.2.0) (2022-04-22)
16 |
17 | ## [1.1.2](https://github.com/thimpat/to-ansi/compare/v1.1.1...v1.1.2) (2022-04-19)
18 |
19 | ## [1.1.1](https://github.com/thimpat/to-ansi/compare/v1.1.0...v1.1.1) (2022-04-19)
20 |
21 | # [1.1.0](https://github.com/thimpat/to-ansi/compare/v1.0.5...v1.1.0) (2022-04-19)
22 |
23 | ## [1.0.5](https://github.com/thimpat/to-ansi/compare/v1.0.4...v1.0.5) (2022-02-18)
24 |
25 | ## [1.0.4](https://github.com/thimpat/to-ansi/compare/v1.0.3...v1.0.4) (2022-02-17)
26 |
27 | ## [1.0.3](https://github.com/thimpat/to-ansi/compare/v1.0.2...v1.0.3) (2022-02-17)
28 |
29 | ## [1.0.2](https://github.com/thimpat/to-ansi/compare/v1.0.1...v1.0.2) (2022-02-17)
30 |
31 | ## [1.0.1](https://github.com/thimpat/to-ansi/compare/v1.0.0...v1.0.1) (2022-02-17)
32 |
33 | # 1.0.0 (2022-02-17)
34 |
--------------------------------------------------------------------------------
/test/node_modules/to-ansi/license.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) [2022] [Patrice Thimothee]
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/test/node_modules/to-ansi/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "to-ansi",
3 | "version": "1.4.3",
4 | "description": "Convert HTML, RGB or HSL to ANSI",
5 | "main": "index.cjs",
6 | "module": "index.mjs",
7 | "type": "module",
8 | "exports": {
9 | ".": {
10 | "require": "./index.cjs",
11 | "import": "./index.mjs"
12 | }
13 | },
14 | "keywords": [
15 | "color",
16 | "convert colors",
17 | "colour",
18 | "console",
19 | "terminal",
20 | "productivity"
21 | ],
22 | "scripts": {
23 | "test": "nyc mocha",
24 | "build:esm": "to-esm.cmd --input=\"index.cjs\" --config=.to-esm.cjs"
25 | },
26 | "author": "Patrice THIMOTHEE",
27 | "license": "MIT",
28 | "homepage": "https://github.com/thimpat/to-ansi/blob/main/README.md",
29 | "repository": {
30 | "type": "git",
31 | "url": "https://github.com/thimpat/to-ansi.git"
32 | },
33 | "devDependencies": {
34 | "@babel/core": "^7.17.4",
35 | "@babel/eslint-parser": "^7.17.0",
36 | "@babel/preset-env": "^7.16.11",
37 | "@semantic-release/changelog": "^6.0.1",
38 | "@semantic-release/commit-analyzer": "^9.0.2",
39 | "@semantic-release/git": "^10.0.1",
40 | "@semantic-release/npm": "^9.0.0",
41 | "@semantic-release/release-notes-generator": "^10.0.3",
42 | "babel-eslint": "^10.1.0",
43 | "chai": "^4.3.6",
44 | "chai-almost": "^1.0.1",
45 | "eslint": "^8.9.0",
46 | "mocha": "^9.2.0",
47 | "nyc": "^15.1.0",
48 | "semantic-release": "^19.0.2",
49 | "to-esm": "^2.9.1"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/test/node_modules/window-size/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2017, Jon Schlinkert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/node_modules/window-size/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var size = require('./');
4 | var helpText = [
5 | 'Usage',
6 | ' $ window-size',
7 | '',
8 | 'Example',
9 | ' $ window-size',
10 | ' height: 40 ',
11 | ' width : 145',
12 | ''
13 | ].join('\n');
14 |
15 | function showSize() {
16 | console.log('height: ' + size.height);
17 | console.log('width : ' + size.width);
18 | }
19 |
20 | switch (process.argv[2]) {
21 | case 'help':
22 | case '--help':
23 | case '-h':
24 | console.log(helpText);
25 | break;
26 | default: {
27 | showSize();
28 | break;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/node_modules/window-size/index.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * window-size
3 | *
4 | * Copyright (c) 2014-2017, Jon Schlinkert.
5 | * Released under the MIT License.
6 | */
7 |
8 | 'use strict';
9 |
10 | var define = require('define-property');
11 | var utils = require('./utils');
12 |
13 | /**
14 | * Expose `windowSize`
15 | */
16 |
17 | module.exports = utils.get();
18 |
19 | if (module.exports) {
20 | /**
21 | * Expose `windowSize.get` method
22 | */
23 |
24 | define(module.exports, 'get', utils.get);
25 |
26 | /**
27 | * Expose methods for unit tests
28 | */
29 |
30 | define(module.exports, 'env', utils.env);
31 | define(module.exports, 'tty', utils.tty);
32 | define(module.exports, 'tput', utils.tput);
33 | define(module.exports, 'win', utils.win);
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test",
3 | "version": "1.0.0",
4 | "dependencies": {
5 | "commondir": "^1.0.1",
6 | "flatted": "^3.2.5",
7 | "rgb-hex": "^4.0.0",
8 | "rgb-hex-cjs": "npm:rgb-hex@^3.0.0",
9 | "to-ansi": "^1.4.3",
10 | "window-size": "^1.1.1"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/test/sandbox/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/*
2 | !.vscode/settings.json
3 | !.vscode/tasks.json
4 | !.vscode/launch.json
5 | !.vscode/extensions.json
6 | *.code-workspace
7 | .history/
8 | .idea/**/workspace.xml
9 | .idea/**/tasks.xml
10 | .idea/**/usage.statistics.xml
11 | .idea/**/dictionaries
12 | .idea/**/shelf
13 | .idea/**/contentModel.xml
14 | .idea/**/dataSources/
15 | .idea/**/dataSources.ids
16 | .idea/**/dataSources.local.xml
17 | .idea/**/sqlDataSources.xml
18 | .idea/**/dynamic.xml
19 | .idea/**/uiDesigner.xml
20 | .idea/**/dbnavigator.xml
21 | .idea/**/gradle.xml
22 | .idea/**/libraries
23 | cmake-build-*/
24 | .idea/**/mongoSettings.xml
25 | *.iws
26 | out/
27 | .idea_modules/
28 | atlassian-ide-plugin.xml
29 | .idea/replstate.xml
30 | com_crashlytics_export_strings.xml
31 | crashlytics.properties
32 | crashlytics-build.properties
33 | fabric.properties
34 | .idea/httpRequests
35 | .idea/caches/build_file_checksums.ser
36 | logs
37 | *.log
38 | npm-debug.log*
39 | yarn-debug.log*
40 | yarn-error.log*
41 | lerna-debug.log*
42 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
43 | pids
44 | *.pid
45 | *.seed
46 | *.pid.lock
47 | lib-cov
48 | coverage
49 | *.lcov
50 | .nyc_output
51 | .grunt
52 | bower_components
53 | .lock-wscript
54 | build/Release
55 | node_modules/
56 | jspm_packages/
57 | web_modules/
58 | *.tsbuildinfo
59 | .npm
60 | .eslintcache
61 | .rpt2_cache/
62 | .rts2_cache_cjs/
63 | .rts2_cache_es/
64 | .rts2_cache_umd/
65 | .node_repl_history
66 | *.tgz
67 | .yarn-integrity
68 | .env
69 | .env.test
70 | .cache
71 | .parcel-cache
72 | .next
73 | out
74 | .nuxt
75 | dist
76 | .cache/
77 | .vuepress/dist
78 | .serverless/
79 | .fusebox/
80 | .dynamodb/
81 | .tern-port
82 | .vscode-test
83 | .yarn/cache
84 | .yarn/unplugged
85 | .yarn/build-state.yml
86 | .yarn/install-state.gz
87 | .pnp.*
88 |
--------------------------------------------------------------------------------
/test/sandbox/example/cjs/contexts-def.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * @type {{C3: null, TEST: {symbol: string, color: string}, STANDARD: {}, C1: null, DEFAULT: {}, C2: null}}
4 | */
5 | module.exports.LOG_CONTEXTS = {STANDARD: {}, TEST: {color: "#B18904", symbol: "⏰"},
6 | TEST2: {color: "rgb(127, 127, 127)", symbol: "⏰"},
7 | TEST3: {color: "blue", symbol: "⏰"},
8 | C1: null, C2: null, C3: null, DEFAULT: {}}
9 | module.exports.LOG_TARGETS = {ALL: "ALL", DEV1: "TOM", DEV2: "TIM", DEV3: "ME", USER: "USER"}
--------------------------------------------------------------------------------
/test/sandbox/example/cjs/something/dummy.cjs:
--------------------------------------------------------------------------------
1 | const t1 = require("./../../../unrelated/t1-cjs.cjs");
2 | const t2 = require("./../../../unrelated/t2.js");
3 | const t3 = require("./../../../unrelated/t3.mjs");
4 |
5 | const t4 = require("./../../../unrelated/deep1/t4-cjs.cjs");
6 | const t5 = require("./../../../unrelated/deep1/t5.js");
7 | const t6 = require("./../../../unrelated/deep1/t6.mjs");
8 |
9 | const t7 = require("./../../../unrelated/deep1/deep2/t7-cjs.cjs");
10 | const t8 = require("./../../../unrelated/deep1/deep2/t8.js");
11 | const t9 = require("./../../../unrelated/deep1/deep2/t9.mjs");
12 |
13 |
14 | console.log(t1, t2, t3, t4, t5, t6, t7, t8, t9);
15 |
--------------------------------------------------------------------------------
/test/sandbox/example/cjs/something/dummy.cjs.js:
--------------------------------------------------------------------------------
1 | const t1 = require("./../../../unrelated/t1-cjs.cjs");
2 | const t2 = require("./../../../unrelated/t2.js");
3 | const t3 = require("./../../../unrelated/t3.mjs");
4 |
5 | const t4 = require("./../../../unrelated/deep1/t4-cjs.cjs");
6 | const t5 = require("./../../../unrelated/deep1/t5.js");
7 | const t6 = require("./../../../unrelated/deep1/t6.mjs");
8 |
9 | const t7 = require("./../../../unrelated/deep1/deep2/t7-cjs.cjs");
10 | const t8 = require("./../../../unrelated/deep1/deep2/t8.js");
11 | const t9 = require("./../../../unrelated/deep1/deep2/t9.mjs");
12 |
13 |
14 | console.log(t1, t2, t3, t4, t5, t6, t7, t8, t9);
15 |
--------------------------------------------------------------------------------
/test/sandbox/example/cjs/something/dummy.js:
--------------------------------------------------------------------------------
1 | const t1 = require("./../../../unrelated/t1-cjs.cjs");
2 | const t2 = require("./../../../unrelated/t2.js");
3 | const t3 = require("./../../../unrelated/t3.mjs");
4 |
5 | const t4 = require("./../../../unrelated/deep1/t4-cjs.cjs");
6 | const t5 = require("./../../../unrelated/deep1/t5.js");
7 | const t6 = require("./../../../unrelated/deep1/t6.mjs");
8 |
9 | const t7 = require("./../../../unrelated/deep1/deep2/t7-cjs.cjs");
10 | const t8 = require("./../../../unrelated/deep1/deep2/t8.js");
11 | const t9 = require("./../../../unrelated/deep1/deep2/t9.mjs");
12 |
13 |
14 | console.log(t1, t2, t3, t4, t5, t6, t7, t8, t9);
15 |
--------------------------------------------------------------------------------
/test/sandbox/example/index.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sourceRoot":"","sources":["index.scss"],"names":[],"mappings":"AAAA;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EAEE;EACA;EACA;;AAEA;EAEE;EACA;EACA;EACA;EACA;;AAGF;EAEE;;AAGF;EAEE;;AAGF;EAEE;;AAGF;EAEE;;AAGF;EAEE;;AAGF;EAEE;;AAGF;EAEE;;AAkBF;EAEE;;AAIJ;EAEE;EACA;EACA;EACA;;AAIJ;EAEE;;AAGF;EAEE;EACA;;AAGF;EAEE;EACA;EACA;EACA","file":"index.css"}
--------------------------------------------------------------------------------
/test/sandbox/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Demo
6 |
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test/sandbox/index.cjs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thimpat/to-esm/a200d5fd789eab00516adef094a670ca63c47abe/test/sandbox/index.cjs
--------------------------------------------------------------------------------
/test/sandbox/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "sandbox",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.cjs",
6 | "scripts": {
7 | "*** Pre-Cleaning ****": "# ----------------------------------------------------------------------------------------------------------",
8 | "clean:generated": "rimraf ./generated && rimraf ./dist",
9 | "*** On the Terminal ****": "# ----------------------------------------------------------------------------------------------------------",
10 | "build:esm:terminal": "npm run clean:generated && to-esm.cmd example/cjs/demo.cjs --output=generated/terminal/ --entrypoint=./src/cjs/ana-logger.cjs --config=.toesm.cjs --target=esm --update-all",
11 | "demo:terminal:esm": "npm run build:esm:terminal && node ./generated/terminal/demo.mjs",
12 | "*** In the Browser ****": "# ----------------------------------------------------------------------------------------------------------",
13 | "build:esm:browser": "npm run clean:generated && to-esm.cmd example/cjs/demo.cjs --output=generated/browser/ --entrypoint=./src/cjs/ana-logger.cjs --config=\".toesm.cjs\" --target=browser --update-all --bundle=\"./dist/analogger-browser.min.mjs\"",
14 | "demo:browser": "npm run build:esm:browser && node example/cjs/demo.cjs",
15 | "*** In the Browser with importmap ****": "# ----------------------------------------------------------------------------------------------------------",
16 | "build:browser:importmap": "npm run build:esm:browser -- --html=example/index.html",
17 | "demo:browser:importmap": "npm run build:browser:importmap && node example/cjs/demo.cjs"
18 | },
19 | "keywords": [],
20 | "author": "",
21 | "license": "ISC",
22 | "dependencies": {
23 | "analogger": "^1.21.4"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/sandbox/test.js:
--------------------------------------------------------------------------------
1 |
2 | const analogger = require("analogger")
3 |
4 | analogger.log("hello world");
--------------------------------------------------------------------------------
/todo.js:
--------------------------------------------------------------------------------
1 | // Major
2 | // TODO: Fix generated entrypoint file location
3 | // TODO: Minify .cjs
4 | // TODO: Add option --update-all-with-minified
5 | // TODO: Check why to-esm can't transform libutils with target browser
6 | //
7 | // Minor
8 | //
--------------------------------------------------------------------------------