fix: update prepublish script to use correct path separator

This commit is contained in:
Andy O'Neill 2023-07-24 13:04:42 -04:00
parent a5bbc4c488
commit 216beb02da

View File

@ -93,13 +93,17 @@ const downloadMicrobitHex = async () => {
const absoluteGeneratedDir = path.join(basePath, relativeGeneratedDir);
fs.mkdirSync(absoluteGeneratedDir, {recursive: true});
const absoluteGeneratedFile = path.join(basePath, relativeGeneratedFile);
const requirePath = `./${path
.relative(relativeGeneratedDir, relativeHexFile)
.split(path.win32.sep)
.join(path.posix.sep)}`;
fs.writeFileSync(
absoluteGeneratedFile,
[
'// This file is generated by scripts/prepublish.mjs',
'// Do not edit this file directly',
'// This file relies on a loader to turn this `require` into a URL',
`module.exports = require('./${path.relative(relativeGeneratedDir, relativeHexFile)}');`,
`module.exports = require('${requirePath}');`,
'' // final newline
].join('\n')
);