Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist
/docs/.vitepress/dist/
/dev/win-to-wsl/logs/
/temp/
/dev/node-fs-utils-dev/tests/dev-specific/temp/
12 changes: 12 additions & 0 deletions .run/ghGenerateAndDeploy.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="ghGenerateAndDeploy" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="ghGenerateAndDeploy" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>
17 changes: 17 additions & 0 deletions .run/spawncmd empty env.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="spawncmd empty env" type="mocha-javascript-test-runner" nameIsGenerated="true">
<node-interpreter>project</node-interpreter>
<node-options />
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
<working-directory>$PROJECT_DIR$</working-directory>
<pass-parent-env>false</pass-parent-env>
<ui>bdd</ui>
<extra-mocha-options />
<test-kind>SUITE</test-kind>
<test-file>$PROJECT_DIR$/dev/node-fs-utils-dev/tests/dev-specific/spawnCmd-cwd.test.mjs</test-file>
<test-names>
<name value="spawncmd empty env" />
</test-names>
<method v="2" />
</configuration>
</component>
18 changes: 18 additions & 0 deletions .run/try pwd (no env)_.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="try pwd (no env)_" type="mocha-javascript-test-runner">
<node-interpreter>project</node-interpreter>
<node-options />
<mocha-package>$PROJECT_DIR$/node_modules/mocha</mocha-package>
<working-directory>$PROJECT_DIR$</working-directory>
<pass-parent-env>false</pass-parent-env>
<ui>bdd</ui>
<extra-mocha-options />
<test-kind>TEST</test-kind>
<test-file>$PROJECT_DIR$/dev/node-fs-utils-dev/tests/dev-specific/spawnCmd-cwd.test.mjs</test-file>
<test-names>
<name value="spawncmd empty env" />
<name value="try pwd no env" />
</test-names>
<method v="2" />
</configuration>
</component>
11 changes: 9 additions & 2 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@
// import {win32ToWin32Slash, win32ToWin32WSL2} from "~/src/win32ToWin32WSL2.mjs";

import {posixTests, win32Tests} from "~/lib/nodePathTestExamples.mjs";
import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "~/lib/dist/index.mjs";

//## not working for some reason
// import {posixTests, win32Tests} from "##/lib/nodePathTestExamples.mjs";
// import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "##/lib/dist/index.mjs";
import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "##/lib/dist/index.mjs";
// import {pathPosixToWin32, pathWin32ToPosix,win32ToWin32JS,win32ToWin32Slash,win32ToWin32WSL2} from "##/lib/dist/index.mjs";
export default {
name:'app',
mounted(){
Expand All @@ -82,7 +85,11 @@ export default {
[
"C:\\Users\\Public\\Documents",
"C:\\\\Users\\\\Public\\\\Documents",
"C:\\Users\\Public\\temp spaces\\a\\b c\\d"
"C:\\Users\\Public\\temp spaces\\a\\b c\\d",
`"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"`,
`C:\\progra~1\\PowerShell\\7\\pwsh.exe`,
`C:\\cygwin64\\bin\\bash.exe`,
`C:\\Windows\\System32\\cmd.exe`
].join('\n'),
}
},
Expand Down
7 changes: 7 additions & 0 deletions dev/node-fs-utils-dev/SpawnCmd.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import { spawn } from 'node:child_process'
import {stdout,stderr} from 'node:process'

/** might be better just to use buffer like they are */
/**
*
* @param cmd
* @param args
* @param opts - {shell:true} or path... to shell?
* @return {Promise<unknown>}
*/
export function spawnExecCmd(cmd,args=[],opts={}){
const actual = {shell:true,...opts}
return new Promise((resolve, reject) => {
Expand Down
19 changes: 17 additions & 2 deletions dev/node-fs-utils-dev/SpawnCmd.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,18 @@ function writeToFile(fileName,data,space=2){
import {promisify} from 'node:util';
import {spawn,spawnSync} from 'node:child_process';
import {spawnExecCmd} from "##/dev/node-fs-utils-dev/SpawnCmd.mjs";
import {cwd} from 'node:process';
function assertEcho(actual,expected){
assert.strictEqual(actual.replace(/\r/g,''),expected);

}
describe('SpawnCmd.test.mjs', function(){
it('spawnExecCmd', async function(){
this.timeout(5000);
let out;
out = await spawnExecCmd('echo hi',[],{shell:true});
// console.log(out);
assert.strictEqual(out.stdout,'hi\n');
assertEcho(out.stdout,'hi\n');
});
it('spawnSync', async function(){
this.timeout(5000);
Expand All @@ -100,10 +104,17 @@ describe('SpawnCmd.test.mjs', function(){
// console.log(out);
//UintArrasy
// const tmp = new Uint8Array(stdout);
assert.strictEqual(hello,'hi\n');
assertEcho(hello,'hi\n');
});

});
/**
* look at
* spawnCmd-cwd.test.mjs
* for device specific
*/

//
describe('SpawnCmd.test.mjs experiments', function(){
/**
* doesnt work
Expand All @@ -116,3 +127,7 @@ describe('SpawnCmd.test.mjs experiments', function(){
console.log(out);
});
});

/**
* env seems to be done in vite-press-docs.git
*/
24 changes: 24 additions & 0 deletions dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env pwsh.exe
<#
node
pwsh.exe dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1
pwsh.exe dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1 -NODE_FIRST_ARG "pwsh-cli"
$env:NODE_FIRST_ARG="pwsh-man-cli";pwsh.exe dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1
#>
# addd params
param(
[string] $NODE_FIRST_ARG="pwsh-int"
)
if(!$env:NODE_FIRST_ARG){
$env:NODE_FIRST_ARG=$NODE_FIRST_ARG
}
# set NODE_FIRST_ARG=$NODE_FIRST_ARG
# get current parent dir
$parentDir = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
#
write-host "$parentDir/temp/$NODE_FIRST_ARG.txt"
c:/progra~1/PowerShell/7/pwsh.exe -c Get-ChildItem env: > "$parentDir/temp/$NODE_FIRST_ARG.txt"
#node "$parentDir/generate-env.mjs"
#which.exe node.exe
node.exe -v
write-host "$parentDir/generate-env.mjs"
15 changes: 15 additions & 0 deletions dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash.exe
# cd /mnt/c/Users/Jason/WebstormProjects/nuxt3-win32-posix-path
# c:/cygwin64/bin/env.exe
cd /mnt/c/Users/Jason/WebstormProjects/nuxt3-win32-posix-path
PROOT="/mnt/c/Users/Jason/WebstormProjects/nuxt3-win32-posix-path"
NODE="/mnt/c/Users/Jason/AppData/Roaming/nvm/v16.20.1/node.exe"
$NODE -v
pwd
# get current file directory
parentDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo $parentDir
echo "$parentDir/generate-env.mjs"
# export NODE_FIRST_ARG="cygwin"; $NODE "$parentDir/generate-env.mjs"
export NODE_PATH="/mnt/c/Users/Jason/WebstormProjects/nuxt3-win32-posix-path/node_modules/.pnpm/node_modules"
export NODE_FIRST_ARG="cygwin"; $NODE "$PROOT/dev/node-fs-utils-dev/tests/dev-specific/generate-env.mjs"
28 changes: 28 additions & 0 deletions dev/node-fs-utils-dev/tests/dev-specific/generate-env.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node
/**
* .....pnpm run dev/node-fs-utils-dev/tests/dev-specific/generate-env.mjs
* assumes pwd is project root
node dev/node-fs-utils-dev/tests/dev-specific/generate-env.mjs
*/
console.log("process.env.NODE_FIRST_ARG:",process.env.NODE_FIRST_ARG);
import { log } from "node:console";
import fs from "node:fs";
import {dirname} from "node:path"
import {fileURLToPath} from "node:url"
console.log("import.meta.url:",import.meta.url);
const __dirname = dirname(fileURLToPath(import.meta.url)); //Folder of current file (from file://url)
function writeToFile(fileName,data,space=2){
const sFileName = /\./.test(fileName) ? fileName : fileName + '.json';
const filePath = `${__dirname}/temp/${sFileName}`
fs.writeFileSync(filePath,
typeof data === 'string' ? data :JSON.stringify(data,null,+space)
);
}

/* get first args */
// const args = process.argv.slice(2);
// console.log(args);
// const [firstArg] = args || ["cli-env"];
const firstArg = process.env.NODE_FIRST_ARG || "cli-env";

writeToFile(`${firstArg}.raw.json`,JSON.stringify(process.env,null,2));//this works... lol interesting
Loading