Skip to content

Commit

Permalink
refactor(*): replace getDirName() with import.meta.dirname (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
Comandeer authored Nov 15, 2024
1 parent 7b048b1 commit c386eb1
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 44 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

---

## [0.25.0]
## [0.25.0] – 2024-11-16
### Added
* [#275]: support for `exports` as a string.

Expand All @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

New dependencies are marked with the "⭐" emoji.
* [#234]: **BREAKING CHANGE**: the transpilation target is now determined by the `engines.node` field in the `package.json` file and default to the `current` version (the one used to run the bundler).
* [#332]: **BREAKING CHANGE**: the minimal supported version of Node.js was bumped to `20.11.0`.


## [0.24.0] – 2024-10-08
Expand Down Expand Up @@ -443,6 +444,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
[#314]: https://github.com/Comandeer/rollup-lib-bundler/issues/314
[#321]: https://github.com/Comandeer/rollup-lib-bundler/issues/321
[#327]: https://github.com/Comandeer/rollup-lib-bundler/issues/327
[#332]: https://github.com/Comandeer/rollup-lib-bundler/issues/332

[0.25.0]: https://github.com/Comandeer/rollup-lib-bundler/compare/v0.24.0...v0.25.0
[0.24.0]: https://github.com/Comandeer/rollup-lib-bundler/compare/v0.23.0...v0.24.0
Expand Down
21 changes: 16 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
},
"engines": {
"node": ">=20.0.0"
"node": ">=20.11.0"
},
"bin": {
"rlb": "bin/rlb.mjs"
Expand Down Expand Up @@ -70,6 +70,7 @@
"devDependencies": {
"@comandeer/eslint-config": "^0.15.0",
"@comandeer/rollup-lib-bundler": "^0.23.0",
"@types/node": "^20.11.0",
"@types/semver": "^7.5.8",
"@types/sinon": "^17.0.3",
"ava": "^6.1.3",
Expand Down
8 changes: 0 additions & 8 deletions src/utils/getDirName.ts

This file was deleted.

4 changes: 1 addition & 3 deletions tests/__helpers__/createTemporaryFixtureDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { cp } from 'node:fs/promises';
import { ExecutionContext } from 'ava';
import { resolve as resolvePath } from 'pathe';
import { temporaryDirectoryTask as tempy } from 'tempy';
import getDirName from '../../src/utils/getDirName.js';

const __dirname = getDirName( import.meta.url );
const FIXTURES_PATH = resolvePath( __dirname, '..', '__fixtures__' );
const FIXTURES_PATH = resolvePath( import.meta.dirname!, '..', '__fixtures__' );

type TemporaryFixtureDirectoryCallback = ( t: ExecutionContext, tempDirPath: string ) => Promise<void> | void;

Expand Down
4 changes: 1 addition & 3 deletions tests/__helpers__/macros/testCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { resolve as resolvePath } from 'pathe';
import test, { ExecutionContext } from 'ava';
import checkDistFiles, { AdditionalCodeCheckCallback, CheckStrategiesMap } from '../checkDistFiles.js';
import createTemporaryFixtureDirectory from '../createTemporaryFixtureDirectory.js';
import getDirName from '../../../src/utils/getDirName.js';

const __dirname = getDirName( import.meta.url );
const BIN_PATH = resolvePath( __dirname, '..', '..', '..', 'src', '__bin__', 'rlb.mts' );
const BIN_PATH = resolvePath( import.meta.dirname!, '..', '..', '..', 'src', '__bin__', 'rlb.mts' );

type TestCLIBeforeCallback = ( t: ExecutionContext, tempDirPath: string ) => Promise<void> | void;
type TestCLIAfterCallback = TestCLIBeforeCallback;
Expand Down
4 changes: 1 addition & 3 deletions tests/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import test from 'ava';
import createPackageMetadata from './__helpers__/createPackageMetadata.js';
import testWithSinonSandbox from './__helpers__/macros/testWithSinonSandbox.js';
import removeArtifacts from './__helpers__/removeArtifacts.js';
import getDirName from '../src/utils/getDirName.js';
import bundler from '../src/bundler.js';

const __dirname = getDirName( import.meta.url );
const fixturesPath = resolvePath( __dirname, '__fixtures__' );
const fixturesPath = resolvePath( import.meta.dirname!, '__fixtures__' );
const errorPackageFixturePath = resolvePath( fixturesPath, 'generic', 'errorPackage' );
const externalDepPackageFixturePath = resolvePath( fixturesPath, 'generic', 'externalDepPackage' );

Expand Down
4 changes: 1 addition & 3 deletions tests/packageParser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import mockFS from 'mock-fs';
import { resolve as resolvePath } from 'pathe';
import test from 'ava';
import getDirName from '../src/utils/getDirName.js';
import packageParser, { DistMetadata, PackageMetadata, PackageMetadataTargets, SubPathMetadata } from '../src/packageParser.js';

const __dirname = getDirName( import.meta.url );
const packageJSONFixtures = {
invalid: '',
empty: {},
Expand Down Expand Up @@ -424,7 +422,7 @@ const INVALID_ESM_METADATA_ERROR = 'Package metadata must contain at least one o
test.before( () => {
mockFS( {
// We need to load node_modules to make sure that we can resolve dependencies.
'node_modules': mockFS.load( resolvePath( __dirname, '../node_modules' ) ),
'node_modules': mockFS.load( resolvePath( import.meta.dirname!, '../node_modules' ) ),
...createMockedPackage( 'invalid', 'js', {
stringify: false
} ),
Expand Down
17 changes: 0 additions & 17 deletions tests/utils/getDirName.ts

This file was deleted.

0 comments on commit c386eb1

Please sign in to comment.