Skip to content

Commit ecdbfd2

Browse files
authored
Mock __dirname (#4402)
1 parent 9c76bb2 commit ecdbfd2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+248
-0
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2017-2021 @polkadot/api-augment authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
declare const __dirname: string | undefined;
5+
6+
export default __dirname;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2017-2021 @polkadot/api-augment authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module.exports = typeof __dirname === 'string'
5+
? __dirname.replace('/cjs', '')
6+
: undefined;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

packages/api-augment/src/detectPackage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
66
import { packageInfo as codecInfo } from '@polkadot/types-codec/packageInfo';
77
import { detectPackage } from '@polkadot/util';
88

9+
import __dirname from './cjs/dirname';
910
import { packageInfo } from './packageInfo';
1011

1112
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [baseInfo, typesInfo, codecInfo]);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
declare const __dirname: string | undefined;
5+
6+
export default __dirname;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
module.exports = typeof __dirname === 'string'
5+
? __dirname.replace('/cjs', '')
6+
: undefined;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

packages/api-base/src/detectPackage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { packageInfo as rpcInfo } from '@polkadot/rpc-core/packageInfo';
55
import { packageInfo as typesInfo } from '@polkadot/types/packageInfo';
66
import { detectPackage } from '@polkadot/util';
77

8+
import __dirname from './cjs/dirname';
89
import { packageInfo } from './packageInfo';
910

1011
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, [rpcInfo, typesInfo]);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
declare const __dirname: string | undefined;
5+
6+
export default __dirname;

0 commit comments

Comments
 (0)