|
1 | 1 | /* eslint require-atomic-updates: off */ |
2 | 2 |
|
3 | | -const AggregateError = require('aggregate-error'); |
4 | | -const getPkg = require('./lib/get-pkg.js'); |
5 | | -const verifyApm = require('./lib/verify.js'); |
6 | | -const prepareApm = require('./lib/prepare.js'); |
7 | | -const publishApm = require('./lib/publish.js'); |
| 3 | +import AggregateError from 'aggregate-error'; |
| 4 | +import getPkg from './lib/get-pkg.js'; |
| 5 | +import verifyApm from './lib/verify.js'; |
| 6 | +import prepareApm from './lib/prepare.js'; |
| 7 | +import publishApm from './lib/publish.js'; |
8 | 8 |
|
9 | 9 | let verified; |
10 | 10 | let prepared; |
11 | 11 |
|
12 | | -async function verifyConditions(pluginConfig, context) { |
13 | | - const errors = await verifyApm(pluginConfig, context); |
| 12 | +const plugin = { |
| 13 | + async verifyConditions(pluginConfig, context) { |
| 14 | + const errors = await verifyApm(pluginConfig, context); |
14 | 15 |
|
15 | | - try { |
16 | | - await getPkg(pluginConfig, context); |
17 | | - } catch (error) { |
18 | | - errors.push(...error); |
19 | | - } |
| 16 | + try { |
| 17 | + await getPkg(pluginConfig, context); |
| 18 | + } catch (error) { |
| 19 | + errors.push(...error.errors); |
| 20 | + } |
20 | 21 |
|
21 | | - if (errors.length > 0) { |
22 | | - throw new AggregateError(errors); |
23 | | - } |
| 22 | + if (errors.length > 0) { |
| 23 | + throw new AggregateError(errors); |
| 24 | + } |
24 | 25 |
|
25 | | - verified = true; |
26 | | -} |
| 26 | + verified = true; |
| 27 | + }, |
27 | 28 |
|
28 | | -async function prepare(pluginConfig, context) { |
29 | | - const errors = verified ? [] : await verifyApm(pluginConfig, context); |
| 29 | + async prepare(pluginConfig, context) { |
| 30 | + const errors = verified ? [] : await verifyApm(pluginConfig, context); |
30 | 31 |
|
31 | | - try { |
32 | | - await getPkg(pluginConfig, context); |
33 | | - } catch (error) { |
34 | | - errors.push(...error); |
35 | | - } |
| 32 | + try { |
| 33 | + await getPkg(pluginConfig, context); |
| 34 | + } catch (error) { |
| 35 | + errors.push(...error.errors); |
| 36 | + } |
36 | 37 |
|
37 | | - if (errors.length > 0) { |
38 | | - throw new AggregateError(errors); |
39 | | - } |
| 38 | + if (errors.length > 0) { |
| 39 | + throw new AggregateError(errors); |
| 40 | + } |
40 | 41 |
|
41 | | - await prepareApm(pluginConfig, context); |
| 42 | + await prepareApm(pluginConfig, context); |
42 | 43 |
|
43 | | - prepared = true; |
44 | | -} |
| 44 | + prepared = true; |
| 45 | + }, |
45 | 46 |
|
46 | | -async function publish(pluginConfig, context) { |
47 | | - let pkg; |
48 | | - const errors = verified ? [] : await verifyApm(pluginConfig, context); |
| 47 | + async publish(pluginConfig, context) { |
| 48 | + let pkg; |
| 49 | + const errors = verified ? [] : await verifyApm(pluginConfig, context); |
49 | 50 |
|
50 | | - try { |
51 | | - pkg = await getPkg(pluginConfig, context); |
52 | | - } catch (error) { |
53 | | - errors.push(...error); |
54 | | - } |
| 51 | + try { |
| 52 | + pkg = await getPkg(pluginConfig, context); |
| 53 | + } catch (error) { |
| 54 | + errors.push(...error.errors); |
| 55 | + } |
55 | 56 |
|
56 | | - if (errors.length > 0) { |
57 | | - throw new AggregateError(errors); |
58 | | - } |
| 57 | + if (errors.length > 0) { |
| 58 | + throw new AggregateError(errors); |
| 59 | + } |
59 | 60 |
|
60 | | - if (!prepared) { |
61 | | - await prepareApm(pluginConfig, context); |
62 | | - prepared = true; |
63 | | - } |
| 61 | + if (!prepared) { |
| 62 | + await prepareApm(pluginConfig, context); |
| 63 | + prepared = true; |
| 64 | + } |
64 | 65 |
|
65 | | - return publishApm(pluginConfig, pkg, context); |
66 | | -} |
| 66 | + return publishApm(pluginConfig, pkg, context); |
| 67 | + }, |
| 68 | +}; |
67 | 69 |
|
68 | | -module.exports = {verifyConditions, prepare, publish}; |
| 70 | +export default plugin; |
0 commit comments