Skip to content

Commit

Permalink
fix window build
Browse files Browse the repository at this point in the history
  • Loading branch information
trusktr committed Jun 26, 2023
1 parent 9dcbc35 commit fabb76b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
4 changes: 1 addition & 3 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import path from 'path';
import { relative } from './util.js';
import { promises as fs } from 'fs';

console.log('import.meta.url:', import.meta.url)
let pkgPath = relative(import.meta.url, '../package.json');
pkgPath = pkgPath.replace('file://', '');
const pkgPath = relative(import.meta, '..', 'package.json');
const pkgString = (await fs.readFile(pkgPath)).toString();
const pkg = JSON.parse(pkgString);
const isProd = process.env.NODE_ENV === 'production';
Expand Down
10 changes: 4 additions & 6 deletions build/cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import fs from 'fs';
import { relative } from './util.js';
var read = fs.readFileSync;
var write = fs.writeFileSync;
let pkgPath = relative(import.meta.url, '../package.json');
pkgPath = pkgPath.replace('file://', '');
const pkgPath = relative(import.meta, '..', 'package.json');
const pkg = JSON.parse(read(pkgPath).toString());
var version = process.env.VERSION || pkg.version;

var coverFile = relative(import.meta.url, '../docs/_coverpage.md');
coverFile = coverFile.replace('file://', '');
var cover = read(coverFile, 'utf8').toString();
var file = relative(import.meta, '..', 'docs', '_coverpage.md');
var cover = read(file, 'utf8').toString();

console.log('Replace version number in cover page...');
cover = cover.replace(
/<small>(\S+)?<\/small>/g,
'<small>' + version + '</small>'
);
write(coverFile, cover);
write(file, cover);
12 changes: 6 additions & 6 deletions build/util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Get an absolute path given a relative path `from` relative to `to`.
* @param {string} from
* @param {string} to
*/
export const relative = (from, to) => new URL(to, from).href;
import url from 'url';
import path from 'path';

/** Get a new path relative to the current module (pass import.meta). */
export const relative = (meta, ...to) =>
path.resolve(path.dirname(url.fileURLToPath(meta.url)), ...to);

0 comments on commit fabb76b

Please sign in to comment.