Skip to content

Commit 79a944b

Browse files
authored
fix(jsr): extract version from url (#1193)
1 parent 8da9803 commit 79a944b

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

build/index.cjs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ __reExport(index_exports, require("./goods.cjs"), module.exports);
3939
var import_vendor2 = require("./vendor.cjs");
4040
var import_util = require("./util.cjs");
4141
var import_meta = {};
42-
var VERSION = (() => {
43-
var _a;
44-
const f = (file) => import_vendor.fs.readJsonSync(new URL(file, import_meta_url), { throws: false });
45-
return (_a = f("../package.json") || f("../jsr.json")) == null ? void 0 : _a.version;
46-
})();
42+
var _a;
43+
var VERSION = ((_a = import_vendor.fs.readJsonSync(new URL("../package.json", import_meta_url), {
44+
throws: false
45+
})) == null ? void 0 : _a.version) || URL.parse(import_meta_url).pathname.split("/")[3];
4746
var version = VERSION;
4847
function nothrow(promise) {
4948
return promise.nothrow();

scripts/build-jsr.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ fs.writeFileSync(
5757
'./core': './src/core.ts',
5858
'./cli': './src/cli.ts',
5959
'./globals': './src/globals-jsr.ts',
60-
'./jsr.json': './jsr.json',
6160
},
6261
publish: {
63-
include: ['src', 'README.md', 'LICENSE', 'jsr.json'],
62+
include: ['src', 'README.md', 'LICENSE'],
6463
exclude: ['src/globals.ts'],
6564
},
6665
nodeModulesDir: 'auto',

src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ export * from './core.ts'
1919
export * from './goods.ts'
2020
export { minimist, dotenv, fs, YAML, glob, glob as globby } from './vendor.ts'
2121

22-
export const VERSION: string = (() => {
23-
const f = (file: string) =>
24-
fs.readJsonSync(new URL(file, import.meta.url), { throws: false })
25-
return (f('../package.json') || f('../jsr.json'))?.version
26-
})()
22+
export const VERSION: string =
23+
fs.readJsonSync(new URL('../package.json', import.meta.url), {
24+
throws: false,
25+
})?.version || URL.parse(import.meta.url)!.pathname.split('/')[3] // extracts version from JSR url
2726

2827
export const version: string = VERSION
2928

0 commit comments

Comments
 (0)