@w5s/configurator-core 1.0.0-alpha.7 → 1.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/yarnConfig.ts CHANGED
@@ -9,7 +9,7 @@ export interface YarnConfigOptions {
9
9
  /**
10
10
  * Option target state
11
11
  */
12
- readonly state: 'present' | 'absent';
12
+ readonly state: 'absent' | 'present';
13
13
 
14
14
  /**
15
15
  * File content mapping function
@@ -19,43 +19,43 @@ export interface YarnConfigOptions {
19
19
  }
20
20
 
21
21
  /**
22
- * Synchronous version of {@link yarnConfig}
22
+ * Set/Unset yarn configuration value
23
23
  *
24
24
  * @param options
25
25
  * @example
26
- * yarnConfigSync({
26
+ * await yarnConfig({
27
27
  * key: 'nodeLinker',
28
28
  * state: 'present',
29
29
  * update: (content) => content.replace('node-modules', 'hoisted'),
30
30
  * })
31
31
  */
32
- export function yarnConfigSync(options: YarnConfigOptions) {
32
+ export async function yarnConfig(options: YarnConfigOptions): Promise<void> {
33
33
  const { key, state, update } = options;
34
34
  if (state === 'present') {
35
- const { stdout } = execSync('yarn', ['config', 'get', String(key)]);
36
- execSync('yarn', ['config', 'set', String(key), `${update == null ? '' : update(stdout)}`]);
35
+ const { stdout } = await exec('yarn', ['config', 'get', String(key)]);
36
+ await exec('yarn', ['config', 'set', String(key), String(update == null ? '' : update(stdout))]);
37
37
  } else {
38
- execSync('yarn', ['config', 'unset']);
38
+ await exec('yarn', ['config', 'unset']);
39
39
  }
40
40
  }
41
41
 
42
42
  /**
43
- * Set/Unset yarn configuration value
43
+ * Synchronous version of {@link yarnConfig}
44
44
  *
45
45
  * @param options
46
46
  * @example
47
- * await yarnConfig({
47
+ * yarnConfigSync({
48
48
  * key: 'nodeLinker',
49
49
  * state: 'present',
50
50
  * update: (content) => content.replace('node-modules', 'hoisted'),
51
51
  * })
52
52
  */
53
- export async function yarnConfig(options: YarnConfigOptions): Promise<void> {
53
+ export function yarnConfigSync(options: YarnConfigOptions) {
54
54
  const { key, state, update } = options;
55
55
  if (state === 'present') {
56
- const { stdout } = await exec('yarn', ['config', 'get', String(key)]);
57
- await exec('yarn', ['config', 'set', String(key), `${update == null ? '' : update(stdout)}`]);
56
+ const { stdout } = execSync('yarn', ['config', 'get', String(key)]);
57
+ execSync('yarn', ['config', 'set', String(key), String(update == null ? '' : update(stdout))]);
58
58
  } else {
59
- await exec('yarn', ['config', 'unset']);
59
+ execSync('yarn', ['config', 'unset']);
60
60
  }
61
61
  }
@@ -6,29 +6,29 @@ export interface YarnVersionOptions {
6
6
  /**
7
7
  * Option target state
8
8
  */
9
- readonly state: 'present' | 'absent';
9
+ readonly state: 'absent' | 'present';
10
10
 
11
11
  /**
12
12
  * Version mapping function
13
13
  *
14
14
  */
15
- readonly update?: (() => YarnVersionKind | undefined) | undefined;
15
+ readonly update?: (() => undefined | YarnVersionKind) | undefined;
16
16
  }
17
17
 
18
18
  /**
19
- * Synchronous version of {@link yarnVersion}
19
+ * Set/Unset yarn configuration value
20
20
  *
21
21
  * @param options
22
22
  * @example
23
- * yarnVersionSync({
23
+ * await yarnVersion({
24
24
  * state: 'present',
25
25
  * update: () => 'berry', // or 'classic'
26
26
  * })
27
27
  */
28
- export function yarnVersionSync(options: YarnVersionOptions) {
28
+ export async function yarnVersion(options: YarnVersionOptions): Promise<void> {
29
29
  const { state, update } = options;
30
30
  if (state === 'present') {
31
- execSync('yarn', ['set', 'version', `${update == null ? 'berry' : update()}`]);
31
+ await exec('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);
32
32
  } else {
33
33
  // TODO: remove yarn.lock
34
34
  throw new Error('Not implemented');
@@ -36,19 +36,19 @@ export function yarnVersionSync(options: YarnVersionOptions) {
36
36
  }
37
37
 
38
38
  /**
39
- * Set/Unset yarn configuration value
39
+ * Synchronous version of {@link yarnVersion}
40
40
  *
41
41
  * @param options
42
42
  * @example
43
- * await yarnVersion({
43
+ * yarnVersionSync({
44
44
  * state: 'present',
45
45
  * update: () => 'berry', // or 'classic'
46
46
  * })
47
47
  */
48
- export async function yarnVersion(options: YarnVersionOptions): Promise<void> {
48
+ export function yarnVersionSync(options: YarnVersionOptions) {
49
49
  const { state, update } = options;
50
50
  if (state === 'present') {
51
- await exec('yarn', ['set', 'version', `${update == null ? 'berry' : update()}`]);
51
+ execSync('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);
52
52
  } else {
53
53
  // TODO: remove yarn.lock
54
54
  throw new Error('Not implemented');