Skip to content

Commit

Permalink
test: add --write option to save changes to "disable" prop
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Oct 29, 2020
1 parent 8b97b72 commit 0b64eb3
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions test/clone.js
Expand Up @@ -26,13 +26,12 @@ const argv = minimist(process.argv.slice(2), {
'offline',
'quick',
'quiet',
'fix'
'fix',
'write'
]
})

let pkgs = argv.quick
? testPkgs.slice(0, 20)
: testPkgs
let pkgs = testPkgs

const disabledPkgs = []
pkgs = pkgs.filter(pkg => {
Expand All @@ -42,9 +41,15 @@ pkgs = pkgs.filter(pkg => {

if (argv.disabled) {
pkgs = disabledPkgs
} else {
}

pkgs = argv.quick
? pkgs.slice(0, 20)
: pkgs

if (!argv.disabled) {
test('Disabled Packages', t => {
disabledPkgs.forEach(pkg => {
pkgs.forEach(pkg => {
console.log(`DISABLED: ${pkg.name}: ${pkg.disable} (${pkg.repo})`)
})
t.end()
Expand Down Expand Up @@ -100,9 +105,11 @@ test('test github repos that use `standard`', t => {
t.comment(`Attempting --fix on ${str}`)
runStandardFix(cb)
} else if (err) {
markDisabled(name, true)
t.fail(str)
cb(null)
} else {
markDisabled(name, false)
t.pass(str)
cb(null)
}
Expand All @@ -127,10 +134,25 @@ test('test github repos that use `standard`', t => {
cb(err)
})
}

function markDisabled (name, disabled) {
const pkg = testPkgs.find(pkg => pkg.name === name)
if (disabled) {
pkg.disable = disabled
} else {
delete pkg.disable
}
}
})
}
}), PARALLEL_LIMIT, err => {
if (err) throw err
if (argv.write) {
fs.writeFileSync(
path.join(__dirname, 'test.json'),
JSON.stringify(testPkgs, null, 2)
)
}
})
})

Expand Down

0 comments on commit 0b64eb3

Please sign in to comment.