Skip to content

Commit f49330f

Browse files
authored
Merge pull request #8 from codeforwings/jc-dev
Jc dev
2 parents 443bb03 + 9e58d60 commit f49330f

21 files changed

+1131
-81
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
inPathWin32.replace(/\\/g,"/");
77
```
88

9+
## Binary Test Strategy
10+
```bash
11+
pnpm run test:unit
12+
pnpm run build-bins
13+
14+
mocha --recursive --timeout 10000 --exit tests/unit
15+
mocha --recursive --timeout 10000 --exit tests/cli/wsl/wsl-cli-to-wsl.test.mjs
16+
npx mocha --recursive --timeout 10000 --exit tests/cli/wsl/wsl-cli-to-wsl.test.mjs
17+
18+
lib/bin_build/dist/index-linux ssdf
19+
```
20+
921
## Next Steps
1022
* Migrate UI to VitePress
1123
* Cleanup and move to src/ and test/ etc.

app.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<textarea class="area"
4646
:value="sOutputWin32ToSlash"
4747
/>
48+
<!-- todo cygwin "/cygdrive/c/" to c:/ -->
4849
</div>
4950
</template>
5051
<script>

dev/node-fs-utils-dev/SpawnCmd.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
3-
*
3+
* og from nuxt3-win32-posix-path/dev/node-fs-utils-dev
44
* spawn for executing commands on controller. make it SSH2Pool like?
55
* future add support for abort / signal
66
*
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env fish
2+
# can't end with \' or \"
3+
# echo 'c\'
4+
# echo "c\"
5+
echo c\
6+
7+
# work
8+
echo 'c\hi'
9+
echo "c\hi"
10+
echo "c\\hi"
11+
echo c\\hi
12+
13+
# no work:
14+
echo c\hi
15+
16+
17+
# Home
18+
echo ~
19+
echo ~/repo
20+
## quotes dont work at all with echo at least
21+
echo "~"
22+
echo '~'
23+
echo "~/repo"
24+
echo '~/repo'
25+
echo "$HOME" # works
26+
echo '$HOME'
27+
echo "$HOME/repo" # works
28+
echo '$HOME/repo'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Cli Escape Lines
2+
* note. literally node cannot see the front slash without quotes
3+
```bash
4+
node ./cli-node.mjs "c:/Users/Public/Docum ents"
5+
node ./cli-node.mjs "c:/Users/Public/Documents"
6+
node ./cli-node.mjs c:/Users/Public/Documents
7+
node ./cli-node.mjs c:\Users\Public\Documents
8+
```
9+
10+
## One
11+
```bash
12+
node ./cli-node.mjs c:\Users\Public\Documents
13+
node ./cli-node.mjs c:\\Users\\Public\\Documents
14+
node ./cli-node.mjs "c:\Users\Public\Documents"
15+
node ./cli-node.mjs 'c:\Users\Public\Documents'
16+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
c\
2+
'c\hi'
3+
"c\hi"
4+
"c\\hi"
5+
c\\hi
6+
c\hi
7+
~
8+
~/repo
9+
"~"
10+
'~'
11+
"~/repo"
12+
'~/repo'
13+
"$HOME"
14+
'$HOME'
15+
"$HOME/repo"
16+
'$HOME/repo'
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/**
2+
yarn add mocha -D
3+
4+
package.json
5+
"imports": {
6+
"##/*": {
7+
"default": "./*"
8+
},
9+
},
10+
"type": "module",
11+
12+
jsconfig.json
13+
{
14+
"compilerOptions": {
15+
"baseUrl": ".",
16+
"paths": {
17+
"##/*": ["./*"]
18+
}
19+
},
20+
"exclude": ["node_modules", ".nuxt", "dist"]
21+
}
22+
23+
24+
25+
*/
26+
// import { createRequire } from 'module';
27+
// const require = createRequire(import.meta.url);
28+
// const assert = require('assert');
29+
// const {describe,it} = require('mocha');
30+
import assert from 'node:assert';
31+
import { describe, it} from 'mocha';
32+
/*
33+
1.
34+
yarn add mocha @babel/polyfill @babel/register @babel/preset-env babel-plugin-module-resolver --dev
35+
yarn add @babel/core --dev
36+
2.
37+
-r @babel/register -r babel-plugin-module-resolver
38+
39+
3.
40+
.babelrc
41+
{
42+
43+
"presets": ["@babel/preset-env"],
44+
"plugins": [
45+
["module-resolver", {
46+
"root": ["./src"],
47+
"alias": {
48+
"test": "./test",
49+
"underscore": "lodash",
50+
51+
"~": "./"
52+
}
53+
}]
54+
]
55+
56+
}
57+
test specific timeout
58+
this.timeout(500);//500ms
59+
*/
60+
/**
61+
* Should put this somewhere safe
62+
* todo filepath needs to be initialized as well...
63+
* @param fileName .json
64+
* @param data will automatically be changed
65+
*/
66+
import fs from 'node:fs';
67+
function writeToFile(fileName,data,space=2){
68+
const sFileName = /\./.test(fileName) ? fileName : fileName + '.json';
69+
const filePath = `dev/pbs/test/${sFileName}`
70+
fs.writeFileSync(filePath,
71+
typeof data === 'string' ? data :JSON.stringify(data,null,+space)
72+
);
73+
}
74+
75+
76+
/**
77+
* todo move / extract
78+
* @param line {string}
79+
* @returns {string|null}
80+
*/
81+
function handleBashLine(line){
82+
/* this regex checks for empty lines and lines with only comments */
83+
if(/^\s*#$/.test(line)) return null;
84+
const rowWithoutComment = line
85+
.replace(/#.*$/,'')
86+
.trim();
87+
if(rowWithoutComment === '') return null;
88+
return rowWithoutComment;
89+
}
90+
describe('handleBashLine', function(){
91+
it('empty line', function(){
92+
const line = '';
93+
const expected = null;
94+
const result = handleBashLine(line);
95+
assert.strictEqual(result,expected);
96+
});
97+
it("comment line", function(){
98+
const line = '# some comments';
99+
const expected = null;
100+
const result = handleBashLine(line);
101+
assert.strictEqual(result,expected);
102+
});
103+
/* need to double check space infront of hash but leave for now */
104+
it('comment at end of line', function(){
105+
const line = 'echo hi # some comments';
106+
const expected = "echo hi";
107+
const result = handleBashLine(line);
108+
assert.strictEqual(result,expected);
109+
});
110+
});
111+
describe('cli-escape-lines.test.mjs', function(){
112+
let filePath = "dev/windows_env_paths/cli-escape-lines.txt.sh"
113+
114+
/** @type {string} */
115+
let rawData;
116+
/** @type {string[]} */
117+
let data;
118+
before(()=>{
119+
/* load file */
120+
rawData = fs.readFileSync(filePath,'utf8')
121+
.replace(/\r\n/g,'\n');
122+
data = rawData.split('\n')
123+
});
124+
it('Ignore # and empty lines', function(){
125+
//assert.strictEqual(1,1);//require assert
126+
assert.strictEqual(typeof rawData,'string');
127+
/* open write stream */
128+
const ws = fs.createWriteStream('dev/windows_env_paths/cli-escape-lines.parsed.txt');
129+
for (let i = 0; i < data.length; i++) {
130+
const line = data[i];
131+
const row = handleBashLine(line);
132+
if(row === null) continue;
133+
ws.write(row + '\n');
134+
}
135+
136+
ws.end();
137+
138+
});
139+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
c\
2+
'c\hi'
3+
"c\hi"
4+
"c\\hi"
5+
c\\hi
6+
# no work:
7+
c\hi
8+
# Home
9+
~
10+
~/repo
11+
## quotes dont work at all with at least
12+
"~"
13+
'~'
14+
"~/repo"
15+
'~/repo'
16+
"$HOME" # works
17+
'$HOME'
18+
"$HOME/repo" # works
19+
'$HOME/repo'

dev/windows_env_paths/cli-node.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Testing how zsh passes arguments to node
3+
node dev/windows_env_paths/cli-node.mjs "c:/Users/Public/Docum ents"
4+
* @type {string[]}
5+
*/
6+
const args = process.argv.slice(2);
7+
console.log(args,args[0][2],'len: ',args.length);

dev_docs/windows_env_paths/readme_windows_env.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,21 @@ ls env:
4646
```
4747

4848
# using pkg to export the exe
49-
* for cross platform url util?
49+
* for cross platform url util?
50+
51+
52+
# also program files
53+
```powershell
54+
<#
55+
c:/progra~1/
56+
c:/progra~2/
57+
c:/progra~3/
58+
#3 is program data
59+
$env:PUBLIC
60+
%PUBLIC%
61+
"/cygdrive/c/"
62+
63+
#>
64+
```
65+
* node uses CMD envs...
66+
* note use process.env

0 commit comments

Comments
 (0)