Skip to content

Commit 36c58c4

Browse files
committed
chore: add skip for repository config
1 parent 578e020 commit 36c58c4

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ Follow the example on `easyclone.example.yaml`
88

99
## Config
1010

11-
- `root` (default: `.`): Location of the moodle base or any project
12-
- `strict` (default: `false`): see explanation of `repositories.enable`
11+
- `root` (default: `.`): location of the moodle base or any project
12+
- `strict` (default: `false`): if `true` delete `repositories.target` if `repositories.enable` is `true` and `repositories.target` directory is exist
1313
- `force` (default: `false`): if `true` it will not ask confirmation when deleting folder
14-
- `skip` (default: `false`): skip install when `repositories.target` exist. **Warning!** This config have lower priority than `repositories.enable` and `strict`, so even if `skip` is `true` but `repositories.enable` is `false` and `strict` is `true`, it will still delete the existing directory
1514
- `cleanup`(default: `[.git, .github]`): array of string which files or folders will be deleted after installing plugin
15+
- `skip` (default: `false`): if `repositories.enable` is `true` and `strict` is `false`, will `skip` installation
1616
- `repositories`:
1717
- `url`: URL of the repo, can be `org/repo` for Github repositories or absolute URL `https://gitlab.com/org/repo.git`. **Mutually exclusive with `path`**
1818
- `branch` (optional): specify branch or tag otherwise it will clone the latest. Only when `url` is specified
1919
- `hash` (optional): specify hash. This will skip `branch` config if specified. Only when `url` is specified
2020
- `path`: path to the plugin for local directory. **Mutually exclusive with `url`**
2121
- `target`: location to install
22-
- `enable` (default: `true`): if `strict` is `true` and this value is `false` it will delete existing directory, otherwise it will just skip installing if `false`
22+
- `enable` (default: `true`): enable installation of the plugin. See `skip` and `strict` for how to delete existing plugin
23+
- `skip` (optional, boolean): same as parent config `skip` but takes higher priority if set
2324
- `cleanup` (default: `[]`): Same as `cleanup` parent config but specific files or folders per plugin
2425

2526
### Environment Variables

deno.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "0.1.1",
23
"imports": {
34
"@std/assert": "jsr:@std/assert@1",
45
"@std/cli": "jsr:@std/cli@^1.0.13",

main.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const repositorySchema = yup
2222
target: yup.string().required(),
2323
branch: yup.string().optional(),
2424
hash: yup.string().optional(),
25+
skip: yup.boolean().optional(),
2526
enable: yup.boolean().required().default(true),
2627
cleanup: yup.array().of(yup.string().required()).required().default([]),
2728
})
@@ -178,21 +179,25 @@ const processRepository = async (
178179
) => {
179180
const target = join(rootConfig.root, repo.target);
180181

181-
if (!repo.enable && rootConfig.strict && (await isDirExists(target))) {
182+
const isTargetExists = await isDirExists(target);
183+
184+
if (!repo.enable && rootConfig.strict && isTargetExists) {
182185
if (!rootConfig.force && !ask(`Are you sure you want to delete ${target}?`))
183186
return;
184187
await rm(target);
185188
return;
186189
}
187190

188-
if (repo.enable && rootConfig.skip && (await isDirExists(target))) {
191+
const skip = repo.skip ?? rootConfig.skip;
192+
193+
if (skip === true && repo.enable === true && isTargetExists) {
189194
console.log(`Skipping: ${target}`);
190195
return;
191196
}
192197

193198
if (repo.enable) {
194199
if (
195-
(await isDirExists(target)) &&
200+
isTargetExists &&
196201
!rootConfig.force &&
197202
!ask(`Target ${target} exists. Delete?`)
198203
)

0 commit comments

Comments
 (0)