Content-Length: 312585 | pFad | http://github.com/micropython/micropython/commit/9681a66c6b79a5f4721c74b756256336c47c9879

E2 webassembly/api: Fix importing micropython.mjs module from node REPL. · micropython/micropython@9681a66 · GitHub
Skip to content

Commit 9681a66

Browse files
committed
webassembly/api: Fix importing micropython.mjs module from node REPL.
Fixes issue #14363. Signed-off-by: Damien George <damien@micropython.org>
1 parent a521df2 commit 9681a66

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Diff for: ports/webassembly/api.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -262,22 +262,25 @@ if (
262262
typeof process.versions === "object" &&
263263
typeof process.versions.node === "string"
264264
) {
265-
// Check if this module is ron from the command line.
265+
// Check if this module is run from the command line via `node micropython.mjs`.
266266
//
267267
// See https://stackoverflow.com/questions/6398196/detect-if-called-through-require-or-directly-by-command-line/66309132#66309132
268268
//
269269
// Note:
270270
// - `resolve()` is used to handle symlinks
271271
// - `includes()` is used to handle cases where the file extension was omitted when passed to node
272272

273-
const path = await import("path");
274-
const url = await import("url");
273+
if (process.argv.length > 1) {
274+
const path = await import("path");
275+
const url = await import("url");
275276

276-
const pathToThisFile = path.resolve(url.fileURLToPath(import.meta.url));
277-
const pathPassedToNode = path.resolve(process.argv[1]);
278-
const isThisFileBeingRunViaCLI = pathToThisFile.includes(pathPassedToNode);
277+
const pathToThisFile = path.resolve(url.fileURLToPath(import.meta.url));
278+
const pathPassedToNode = path.resolve(process.argv[1]);
279+
const isThisFileBeingRunViaCLI =
280+
pathToThisFile.includes(pathPassedToNode);
279281

280-
if (isThisFileBeingRunViaCLI) {
281-
runCLI();
282+
if (isThisFileBeingRunViaCLI) {
283+
runCLI();
284+
}
282285
}
283286
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micropython/micropython/commit/9681a66c6b79a5f4721c74b756256336c47c9879

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy