From 8174451d10df7a3bcc909e4d449b3880a4582c30 Mon Sep 17 00:00:00 2001 From: Yoav Vainrich Date: Sat, 1 Jul 2023 20:34:01 +0300 Subject: [PATCH 1/3] doc: fix copy node executable in Windows Windows where command lists all places it finds a pattern in Path. The first one is the one that executes when called. So the old code was overriding the first executable by any other match. --- doc/api/single-executable-applications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/single-executable-applications.md b/doc/api/single-executable-applications.md index 2dedd17527ba87..6be2cde63c8a5c 100644 --- a/doc/api/single-executable-applications.md +++ b/doc/api/single-executable-applications.md @@ -67,7 +67,7 @@ tool, [postject][]: Using Command Prompt: ```text - for /F "tokens=*" %n IN ('where.exe node') DO @(copy "%n" hello.exe) + set "node_path=" && for /F "tokens=*" %n IN ('where.exe node') DO @if not defined node_path (set "node_path=%n" && copy "%n" hello.exe) ``` The `.exe` extension is necessary. From 4adbf5aed59b87556f42fb3f39e2181beef10bb4 Mon Sep 17 00:00:00 2001 From: Yoav Vainrich Date: Sun, 2 Jul 2023 12:03:11 +0300 Subject: [PATCH 2/3] doc: fix copy node executable in Windows Found a much easier solution for copying the node executable using native node. Can probably be consolidated to all OSs. --- doc/api/single-executable-applications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/single-executable-applications.md b/doc/api/single-executable-applications.md index 6be2cde63c8a5c..428c4e1297864c 100644 --- a/doc/api/single-executable-applications.md +++ b/doc/api/single-executable-applications.md @@ -67,7 +67,7 @@ tool, [postject][]: Using Command Prompt: ```text - set "node_path=" && for /F "tokens=*" %n IN ('where.exe node') DO @if not defined node_path (set "node_path=%n" && copy "%n" hello.exe) + node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')" ``` The `.exe` extension is necessary. From 32bdacde9931ebb36f04d9865d9ea1ddcc03ab4d Mon Sep 17 00:00:00 2001 From: Yoav Vainrich Date: Tue, 4 Jul 2023 17:54:54 +0300 Subject: [PATCH 3/3] doc: fix copy node executable in Windows Merged command for both PowerShell and Command Prompt --- doc/api/single-executable-applications.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/doc/api/single-executable-applications.md b/doc/api/single-executable-applications.md index 428c4e1297864c..2db06fdd7239e1 100644 --- a/doc/api/single-executable-applications.md +++ b/doc/api/single-executable-applications.md @@ -58,14 +58,6 @@ tool, [postject][]: * On Windows: - Using PowerShell: - - ```powershell - cp (Get-Command node).Source hello.exe - ``` - - Using Command Prompt: - ```text node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')" ```