Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal optimizations #244

Merged
merged 15 commits into from
Nov 29, 2023
68 changes: 43 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@ on: [workflow_dispatch]

jobs:
test:
name: Test
name: Test Copy [${{matrix.os}}] (existing ${{matrix.exists}})
timeout-minutes: 2
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
exists: [true, false]
steps:
- name: Create File
shell: bash
run: |
echo "A" > A.txt
echo "B" > B.txt
echo "A" > A
echo "B" > B

- name: Copy (Windows)
if: matrix.os == 'windows-latest'
run: xcopy /r /y "A.txt" "C.txt*" && xcopy /r /y "B.txt" "D.txt*"

- name: Copy (Linux)
if: matrix.os == 'ubuntu-latest'
run: cp -f 'A.txt' 'C.txt' && cp -f 'B.txt' 'D.txt'

- name: Copy (Mac)
if: matrix.os == 'macos-latest'
run: cp -f 'A.txt' 'C.txt' && cp -f 'B.txt' 'D.txt'
- name: Create Existing File
shell: bash
if: matrix.exists
run: |
echo "A" > C.txt
echo "B" > D.txt

- name: List Files
shell: bash
Expand All @@ -37,16 +33,38 @@ jobs:
uses: actions/github-script@v7
with:
script: |
const win = process.platform === "win32"

const cp = (files, asterisk = false) => {
let commands = [];
for(const file of files)
commands.push(win
? `xcopy /r /y "${file[0]}" "${file[1]}${asterisk ? '*' : ''}"`
: `cp -f '${file[0]}' '${file[1]}'`);
return commands.join(" && ");
const existsSync = require("fs").existsSync;
const windows = process.platform === "win32"

const cp = (files) => {
return files
.map((file) =>
windows
? (!existsSync(file[1]) ? `echo "NUL" > "${file[1]}" && ` : '') +
`xcopy /r /y "${file[0]}" "${file[1]}"`
: `cp -f '${file[0]}' '${file[1]}'`
)
.join(" && ");
};

console.log(cp([["A.txt", "C.txt"], ["B.txt", "D.txt"]]));
console.log(cp([["A.txt", "C.txt"], ["B.txt", "D.txt"]], true));
console.log(cp([["A", "C.txt"], ["B", "D.txt"]]));

- name: Copy (Windows)
if: matrix.os == 'windows-latest' && !matrix.exists
run: echo "NUL" > "C.txt" && xcopy /r /y "A" "C.txt" && echo "NUL" > "D.txt" && xcopy /r /y "B" "D.txt"

- name: Copy Existing (Windows)
if: matrix.os == 'windows-latest' && matrix.exists
run: xcopy /r /y "A" "C.txt" && xcopy /r /y "B" "D.txt"

- name: Copy (Linux)
if: matrix.os == 'ubuntu-latest'
run: cp -f 'A' 'C.txt' && cp -f 'B' 'D.txt'

- name: Copy (Mac)
if: matrix.os == 'macos-latest'
run: cp -f 'A' 'C.txt' && cp -f 'B' 'D.txt'

- name: List Files
shell: bash
run: ls
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"theme": "dark"
},
"publisher": "Katsute",
"version": "2.8.3",
"version": "2.9.0",
"private": true,
"engines": {
"vscode": "^1.84.2"
Expand Down
206 changes: 0 additions & 206 deletions src/command/config.ts

This file was deleted.

Loading