Skip to content

Commit

Permalink
Implement run-in-root in dots-node-recurse.
Browse files Browse the repository at this point in the history
See #76.
  • Loading branch information
flatheadmill committed Oct 27, 2019
1 parent e18056b commit 2db5738
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions bin/dots-node-recurse
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
-t, --tag <string>
The release note tag to update.
-r, --root
Run command in root directoy of multi-package repos.
___ $ ___ en_US ___
repository url not shorthand(url):
Expand All @@ -30,7 +33,7 @@ require('arguable')(module, async arguable => {
const once = require('prospective/once')
const _module = require('module')

const seen = {}
const seen = { module: {}, directory: {} }
const skip = {}

for (const skipping of arguable.arrayed.skip) {
Expand Down Expand Up @@ -90,14 +93,29 @@ require('arguable')(module, async arguable => {
async function project (directory) {
const _require = _module.createRequire(`${directory}/`)
const current = _require('./package.json')
if (seen[current.name]) {
if (seen.module[current.name]) {
return 0
}
seen[current.name] = true
if (!(skip[current.name] || skip['.top'])) {
seen.module[current.name] = true
let _directory = directory
if (arguable.ultimate.root) {
try {
await fs.stat(path.resolve(_directory, '.git'))
} catch (error) {
if (error.code != 'ENOENT') {
throw error
}
_directory = path.dirname(_directory)
}
}
if (skip[current.name] || skip['.top']) {
console.log(`--- ${current.name} (skip) ---`)
} else if (seen.directory[_directory]) {
console.log(`--- ${current.name} (root seen) ---`)
} else {
console.log(`--- ${current.name} ---`)
const child = processes.spawn(arguable.argv[0], arguable.argv.slice(1), {
cwd: directory,
cwd: _directory,
stdio: 'inherit'
})
const [ code, signal ] = await once(child, 'exit').promise
Expand All @@ -106,6 +124,7 @@ require('arguable')(module, async arguable => {
return code || 1
}
}
seen.directory[_directory] = true
skip['.top'] = false
for (const property of [ 'dependencies', 'devDependencies' ]) {
for (const name in current[property]) {
Expand Down

0 comments on commit 2db5738

Please sign in to comment.