Skip to content

Commit 7d6bfdb

Browse files
author
Your Name
committed
Fix command line flags for cache
1 parent 8165775 commit 7d6bfdb

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
- name: Download tools
8888
run: |
8989
yarn --frozen-lockfile --ignore-scripts --prefer-offline
90-
yarn download-tools --target ${{ matrix.target }}
90+
yarn download-tools --target ${{ matrix.target }} --no-cache
9191
9292
- name: Create vsix package
9393
run: |

DEVELOPMENT.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
## Building
1515

16-
Major parts are platform independent but due to the inclusion of binary tools the resulting packages become platform-specific, i.e. for on `<target>`.
16+
Major parts are platform independent but due to the inclusion of binary tools the resulting
17+
packages become platform-specific, i.e. for on `<target>`.
1718

1819
Supported `<target>`s are:
1920

@@ -24,7 +25,8 @@ Supported `<target>`s are:
2425
- darwin-x64 (MacOS, Intel, x86-64)
2526
- darwin-arm64 (MacOS, Arm, aarch64)
2627

27-
1. Open a terminal and execute the following command to download NPM dependencies and tools, and to build the Typescript code:
28+
1. Open a terminal and execute the following command to download NPM dependencies and tools, and
29+
to build the Typescript code:
2830

2931
```sh
3032
> yarn
@@ -33,10 +35,12 @@ Supported `<target>`s are:
3335
2. Download binary tools
3436

3537
```sh
36-
> yarn download-tools [--target <target>]
38+
> yarn download-tools [--target <target>] [--no-cache]
3739
```
3840

3941
If no `<target>` is specified the local system's architecture is used by default.
42+
By default, tool downloads are cached in the yarn cache (see `yarn cache dir`) to prevent
43+
recurring downloads of exact same archives on clean builds.
4044
4145
3. Package the extension as a locally installable VSIX file:
4246
@@ -46,13 +50,16 @@ Supported `<target>`s are:
4650
4751
## Developing
4852
49-
1. If you are developing and debugging this extension, we recommend you run the following command after an initial build:
53+
1. If you are developing and debugging this extension, we recommend you run the following command
54+
after an initial build:
5055
5156
```sh
5257
> yarn watch
5358
```
5459
55-
While just calling `yarn` creates a production build of the extension, running the above creates a build dedicated for debug. Additionally, it sets up a watch which detects code changes and rebuilds them incrementally.
60+
While just calling `yarn` creates a production build of the extension, running the above
61+
creates a build dedicated for debug. Additionally, it sets up a watch which detects code
62+
changes and rebuilds them incrementally.
5663
5764
2. Switch to the VS Code `Run and Debug` view.
5865

scripts/download-tools.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async function main() {
197197
const yarnCacheDir = execSync('yarn cache dir').toString().trim();
198198
console.debug(`Yarn cache directory: ${yarnCacheDir}`);
199199

200-
const { target, dest, cache, cache_disable, tools } = yargs
200+
const { target, dest, cache, tools } = yargs
201201
.option('t', {
202202
alias: 'target',
203203
description: 'VS Code extension target, defaults to system',
@@ -214,11 +214,6 @@ async function main() {
214214
description: 'Directory for caching tool downloads',
215215
default: yarnCacheDir
216216
})
217-
.option('no-cache', {
218-
description: 'Disable caching of tool downloads',
219-
type: 'boolean',
220-
default: false
221-
})
222217
.version(false)
223218
.strict()
224219
.command('$0 [<tools> ...]', 'Downloads the tool(s) for the given architecture and OS', y => {
@@ -229,14 +224,23 @@ async function main() {
229224
default: Object.keys(TOOLS)
230225
});
231226
})
232-
.argv as unknown as { target: VsceTarget, dest: string, cache: string, cache_disable: boolean, tools: (keyof typeof TOOLS)[] };
227+
.argv as unknown as { target: VsceTarget, dest: string, cache: string | boolean, tools: (keyof typeof TOOLS)[] };
233228

234229
if (!existsSync(dest)) {
235230
mkdirSync(dest, { recursive: true });
236231
}
237232

233+
const cacheFolder = (cache: string | boolean) => {
234+
if (typeof cache === 'string') {
235+
return cache;
236+
} else if(cache === true) {
237+
return yarnCacheDir;
238+
}
239+
return undefined;
240+
}
241+
238242
for (const tool of new Set(tools)) {
239-
TOOLS[tool](target, dest, { cache: cache_disable ? undefined : cache });
243+
TOOLS[tool](target, dest, { cache: cacheFolder(cache) });
240244
}
241245
}
242246

0 commit comments

Comments
 (0)