Skip to content

Commit

Permalink
Move scripts to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 23, 2023
1 parent 99308fa commit ee962b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
7 changes: 4 additions & 3 deletions scripts/bump → scripts/bump.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env node

let { readdirSync, readFileSync, writeFileSync, existsSync } = require('fs')
let { join } = require('path')
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'

const PACKAGES = join(__dirname, '..', 'packages')
const PACKAGES = join(fileURLToPath(import.meta.url), '..', '..', 'packages')

let version = process.argv[2]
if (!version) {
Expand Down
19 changes: 10 additions & 9 deletions scripts/each → scripts/each.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env node

let { readdirSync, existsSync } = require('fs')
let { spawn } = require('child_process')
let { join } = require('path')
import { spawn } from 'node:child_process'
import { existsSync, readdirSync } from 'node:fs'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'

const PACKAGES = join(__dirname, '..', 'packages')
const PACKAGES = join(fileURLToPath(import.meta.url), '..', '..', 'packages')

let command = process.argv[2]
let args = process.argv.slice(3)

let dirs = readdirSync(PACKAGES)

function nextTick () {
function nextTick() {
if (dirs.length === 0) return
let dir = dirs.pop()

Expand All @@ -20,12 +21,12 @@ function nextTick () {
return
}

process.stdout.write(`$ cd packages/${ dir }\n`)
process.stdout.write(`$ ${ command } ${ args.join(' ') }\n`)
process.stdout.write(`$ cd packages/${dir}\n`)
process.stdout.write(`$ ${command} ${args.join(' ')}\n`)
let run = spawn(command, args, {
stdio: 'inherit',
cwd: join(PACKAGES, dir),
env: process.env
env: process.env,
stdio: 'inherit'
})
run.on('close', exitCode => {
if (exitCode === 0) {
Expand Down

0 comments on commit ee962b2

Please sign in to comment.