Skip to content

Commit b6969f7

Browse files
committed
improve test-deprecations output
1 parent ed61a3a commit b6969f7

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

script/test-deprecations.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ If either check fails, the process exits with an error status (1).
3131
}
3232

3333
Promise.all([checkSelectorDeprecations(args), checkVariableDeprecations(args)]).then(
34-
(deprecationErrors, variableErrors) => {
35-
const errors = deprecationErrors.concat(variableErrors)
34+
([deprecationErrors, variableErrors]) => {
35+
const errors = [...deprecationErrors, ...variableErrors]
3636
if (errors.length) {
37+
console.log(`\n${errors.length} error${errors.length === 1 ? '' : 's'}:`)
38+
for (const error of errors) {
39+
console.log(`${X} ${error}`)
40+
}
3741
process.exit(1)
42+
} else {
43+
console.log(`${V} no errors!`)
3844
}
3945
}
4046
)
@@ -50,27 +56,30 @@ async function checkSelectorDeprecations(options = {}) {
5056

5157
const {changed, added, removed} = diffLists(remote.selectors.values, local.selectors.values)
5258
if (changed === 0) {
53-
console.log(`no selectors added or removed in bundle "${bundle}"`)
54-
return
59+
console.log(`${I} no selectors changed in bundle "${bundle}" (${version} -> ${currentVersion})`)
60+
// return
5561
}
5662

5763
const deprecations = versionDeprecations[currentVersion] || []
5864
const deprecatedSelectors = deprecations.reduce((list, deprecation) => list.concat(deprecation.selectors), [])
59-
console.log(`${I} ${removed.length} selectors removed locally (compared with ${version})`)
60-
console.log(`${I} ${deprecatedSelectors.length} selectors deprecated in v${currentVersion}`)
65+
if (removed.length) {
66+
console.log(`${I} ${removed.length} selectors removed locally (compared with ${version})`)
67+
}
68+
if (deprecatedSelectors.length) {
69+
console.log(`${I} ${deprecatedSelectors.length} selectors to be deprecated in ${currentVersion}`)
70+
}
6171
if (added.length) {
6272
console.log(`${I} ${added.length} selectors added`)
6373
}
6474

6575
const errors = []
66-
for (const deprecation of deprecations) {
67-
for (const selector of deprecation.selectors) {
76+
for (const {selectors = []} of deprecations) {
77+
for (const selector of selectors) {
6878
if (!removed.includes(selector)) {
6979
const error = `"${selector}" deprecated, but not removed`
7080
errors.push(error)
71-
console.log(`${X} ${error}`)
7281
} else {
73-
console.log(`${V} "${selector}" is officially deprecated`)
82+
console.log(`${V} selector "${selector}" is officially deprecated`)
7483
}
7584
deprecatedSelectors.push(selector)
7685
}
@@ -80,7 +89,6 @@ async function checkSelectorDeprecations(options = {}) {
8089
if (!deprecatedSelectors.includes(removedSelector)) {
8190
const error = `"${removedSelector}" has been removed, but was not listed in versionDeprecations['${currentVersion}']`
8291
errors.push(error)
83-
console.log(`${X} ${error}`)
8492
} else {
8593
// console.log(`${V} "${removedSelector}" removed and deprecated!`)
8694
}
@@ -100,27 +108,30 @@ async function checkVariableDeprecations(options = {}) {
100108

101109
const {changed, added, removed} = diffLists(Object.keys(remote), Object.keys(local))
102110
if (changed === 0) {
103-
console.log(`no variables added or removed in version ${currentVersion}`)
104-
return
111+
console.log(`${I} no variables changed (${version} -> ${currentVersion})`)
112+
// return
105113
}
106114

107115
const deprecations = versionDeprecations[currentVersion] || []
108116
const deprecatedVariables = deprecations.reduce((list, deprecation) => list.concat(deprecation.variables), [])
109-
console.log(`${I} ${removed.length} variables removed locally (compared with ${version})`)
110-
console.log(`${I} ${deprecatedVariables.length} variables deprecated in v${currentVersion}`)
117+
if (removed.length) {
118+
console.log(`${I} ${removed.length} variables removed locally (compared with ${version})`)
119+
}
120+
if (deprecatedVariables.length) {
121+
console.log(`${I} ${deprecatedVariables.length} variables to be deprecated in ${currentVersion}`)
122+
}
111123
if (added.length) {
112124
console.log(`${I} ${added.length} variables added`)
113125
}
114126

115127
const errors = []
116-
for (const deprecation of deprecations) {
117-
for (const variable of deprecation.variables) {
128+
for (const {variables = []} of deprecations) {
129+
for (const variable of variables) {
118130
if (!removed.includes(variable)) {
119131
const error = `variable "${variable}" deprecated, but not removed`
120132
errors.push(error)
121-
console.log(`${X} ${error}`)
122133
} else {
123-
console.log(`${V} "${variable}" is officially deprecated`)
134+
console.log(`${V} variable "${variable}" is officially deprecated`)
124135
}
125136
deprecatedVariables.push(variable)
126137
}
@@ -130,7 +141,6 @@ async function checkVariableDeprecations(options = {}) {
130141
if (!deprecatedVariables.includes(removedVariable)) {
131142
const error = `"${removedVariable}" has been removed, but was not listed in versionDeprecations['${currentVersion}']`
132143
errors.push(error)
133-
console.log(`${X} ${error}`)
134144
} else {
135145
// console.log(`${V} "${removedVariable}" removed and deprecated!`)
136146
}

0 commit comments

Comments
 (0)