Skip to content

Commit fabb76b

Browse files
committed
fix window build
1 parent 9dcbc35 commit fabb76b

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

build/build.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import path from 'path';
99
import { relative } from './util.js';
1010
import { promises as fs } from 'fs';
1111

12-
console.log('import.meta.url:', import.meta.url)
13-
let pkgPath = relative(import.meta.url, '../package.json');
14-
pkgPath = pkgPath.replace('file://', '');
12+
const pkgPath = relative(import.meta, '..', 'package.json');
1513
const pkgString = (await fs.readFile(pkgPath)).toString();
1614
const pkg = JSON.parse(pkgString);
1715
const isProd = process.env.NODE_ENV === 'production';

build/cover.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ import fs from 'fs';
22
import { relative } from './util.js';
33
var read = fs.readFileSync;
44
var write = fs.writeFileSync;
5-
let pkgPath = relative(import.meta.url, '../package.json');
6-
pkgPath = pkgPath.replace('file://', '');
5+
const pkgPath = relative(import.meta, '..', 'package.json');
76
const pkg = JSON.parse(read(pkgPath).toString());
87
var version = process.env.VERSION || pkg.version;
98

10-
var coverFile = relative(import.meta.url, '../docs/_coverpage.md');
11-
coverFile = coverFile.replace('file://', '');
12-
var cover = read(coverFile, 'utf8').toString();
9+
var file = relative(import.meta, '..', 'docs', '_coverpage.md');
10+
var cover = read(file, 'utf8').toString();
1311

1412
console.log('Replace version number in cover page...');
1513
cover = cover.replace(
1614
/<small>(\S+)?<\/small>/g,
1715
'<small>' + version + '</small>'
1816
);
19-
write(coverFile, cover);
17+
write(file, cover);

build/util.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/**
2-
* Get an absolute path given a relative path `from` relative to `to`.
3-
* @param {string} from
4-
* @param {string} to
5-
*/
6-
export const relative = (from, to) => new URL(to, from).href;
1+
import url from 'url';
2+
import path from 'path';
3+
4+
/** Get a new path relative to the current module (pass import.meta). */
5+
export const relative = (meta, ...to) =>
6+
path.resolve(path.dirname(url.fileURLToPath(meta.url)), ...to);

0 commit comments

Comments
 (0)