-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharguments.ts
More file actions
50 lines (44 loc) · 1.26 KB
/
Copy patharguments.ts
File metadata and controls
50 lines (44 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Options, PositionalOptions } from 'yargs';
export declare type AppArguments = {
semver?: string;
from: string;
files: string[];
commit: string;
tidy?: boolean;
};
export declare type FileWithOptions = {
filePath: string;
objectPaths: string[];
};
export const positionalSemver: PositionalOptions = {
type: 'string',
describe: 'initial version',
};
export const optionFrom: Options = {
type: 'string',
alias: 'f',
describe:
'file to grab version from (optionally dot-notated path to version in json object: file.json:meta.version)',
default: 'package.json:version',
};
export const optionFiles: Options = {
type: 'array',
alias: 'o',
describe: 'files to patch version',
default: ['package.json:version', 'package-lock.json:version,packages..version'],
};
export const optionCommit: Options = {
type: 'string',
describe: 'commmit type to save',
};
export const optionTidy: Options = {
type: 'boolean',
describe: 'save only 1.2.3 without sha',
};
export function getFileWithOptions(input: string, defObjectPath = ''): FileWithOptions {
const [filePath, objectPaths = defObjectPath] = input.split(':');
return {
filePath,
objectPaths: objectPaths.split(','),
};
}