mirror of
https://github.com/pyscript/pyscript.git
synced 2026-02-21 11:01:26 -05:00
Fix path errors on Windows systems (#1368)
* Add docs to repl with attr src * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix path errors on Windows systems * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix path errors on Windows systems --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// 1. esbuild.mjs
|
||||
// 2. Jest setup.ts
|
||||
|
||||
import { join } from 'path';
|
||||
import path, { join } from 'path';
|
||||
import { opendir, readFile } from 'fs/promises';
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,16 @@ async function _directoryManifestHelper(root, dir, result) {
|
||||
result.dirs.push(entry);
|
||||
await _directoryManifestHelper(root, entry, result);
|
||||
} else if (d.isFile()) {
|
||||
result.files.push([entry, await readFile(join(root, entry), { encoding: 'utf-8' })]);
|
||||
result.files.push([normalizePath(entry), await readFile(join(root, entry), { encoding: 'utf-8' })]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize paths under different operating systems to
|
||||
* the correct path that will be used for src on browser.
|
||||
* @param {string} originalPath
|
||||
*/
|
||||
function normalizePath(originalPath) {
|
||||
return path.normalize(originalPath).replace(/\\/g, '/');
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { build } from 'esbuild';
|
||||
import { spawn } from 'child_process';
|
||||
import { dirname, join } from 'path';
|
||||
import { join } from 'path';
|
||||
import { watchFile } from 'fs';
|
||||
import { cp, lstat, readdir } from 'fs/promises';
|
||||
import { directoryManifest } from './directoryManifest.mjs';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = dirname(new URL(import.meta.url).pathname);
|
||||
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
||||
|
||||
const production = !process.env.NODE_WATCH || process.env.NODE_ENV === 'production';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user