-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: compat with Berry workspace list results
- Loading branch information
Showing
4 changed files
with
35 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,18 @@ | ||
#! /usr/bin/env node | ||
/* global process, Buffer */ | ||
import { spawn } from 'child_process'; | ||
/* eslint-env node */ | ||
import { basename } from 'path'; | ||
import { listWorkspaces } from '../src/lib/yarn.js'; | ||
|
||
const ps = spawn('yarn', ['workspaces', 'list', '--json'], { | ||
stdio: ['ignore', 'pipe', 'inherit'], | ||
shell: true, | ||
}); | ||
const workspaces = listWorkspaces(); | ||
|
||
// Get Buffers of output. | ||
const chunks = []; | ||
ps.stdout.on('data', data => chunks.push(data)); | ||
const packageNames = workspaces.map(w => w.name); | ||
|
||
// Wait for the process to exit. | ||
ps.on('close', code => { | ||
if (code !== 0) { | ||
throw Error(`yarn info exited with code ${code}`); | ||
} | ||
|
||
// Get the output. | ||
const ndjson = Buffer.concat(chunks).toString('utf8'); | ||
// process.stderr.write(json); | ||
|
||
const packageNames = ndjson | ||
.trim() | ||
.split('\n') | ||
.map(line => JSON.parse(line).name) | ||
.filter(n => n !== '@agoric/sdk'); | ||
|
||
// Write the module. | ||
process.stdout.write(`\ | ||
// Write the module. | ||
process.stdout.write(`\ | ||
// DO NOT EDIT - automatically generated by ${basename( | ||
new URL(import.meta.url).pathname, | ||
)} | ||
new URL(import.meta.url).pathname, | ||
)} | ||
/* eslint-disable comma-dangle,quotes */ | ||
// prettier-ignore | ||
export default ${JSON.stringify(packageNames.sort(), null, 2)}; | ||
`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @ts-check | ||
import { execFileSync } from 'child_process'; | ||
|
||
/** | ||
* Omits the root | ||
* | ||
* @returns {Array<{ location: string, name: string }>} | ||
*/ | ||
export const listWorkspaces = () => { | ||
const ndjson = execFileSync('yarn', ['workspaces', 'list', '--json'], { | ||
stdio: ['ignore', 'pipe', 'inherit'], | ||
shell: true, | ||
encoding: 'utf-8', | ||
}); | ||
return ndjson | ||
.trim() | ||
.split('\n') | ||
.map(line => JSON.parse(line)) | ||
.filter(({ location }) => location !== '.'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters