Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
YieldRay committed Aug 18, 2024
1 parent 33508bf commit 2996a3e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Hence you can install `nrm-lite` in deno, so it will be as fast as `dnrm`.

```sh
# install `nrml` in deno
deno install -Arf npm:nrm-lite -n nrml
deno install -Afgr npm:nrm-lite -n nrml

# test if it's installed
nrml --help
Expand All @@ -50,6 +50,8 @@ Usage:
nrml ls List registries
nrml use <name> Use registry
nrml test [<timeout>] Test registry speed, optional timeout in second (default: 2)
nrml add <name> <url> Add custom registry
nrml del <name> Delete custom registry
nrml rc Open .npmrc file
nrml help Show this help
Global Options:
Expand Down
10 changes: 5 additions & 5 deletions cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ ${c.bold('Usage:')}
nrml ls List registries
nrml use ${c.gray('<name>')} Use registry
nrml test ${c.gray(
'[<timeout>]'
'[<timeout>]',
)} Test registry speed, optional timeout in second (default: 2)
nrml add ${c.gray('<name>')} ${c.gray('<url>')} Add custom registry
nrml del ${c.gray('<name>')} Delete custom registry
Expand Down Expand Up @@ -154,7 +154,7 @@ async function test(timeoutLimit) {
name,
url,
timeSpent: await speedTest(url, timeoutLimit),
}))
})),
)

const currentRegistry = await getRegistry(local)
Expand Down Expand Up @@ -186,8 +186,8 @@ async function add(name, url) {
await appendNrmrc(name, url)
console.log(
`Registry ${c.magenta(name)} has been added, run ${c.green(
`nrml use ${name}`
)} to use.`
`nrml use ${name}`,
)} to use.`,
)
}
}
Expand Down Expand Up @@ -229,7 +229,7 @@ async function rc() {
if (shouldRunEditor) execSync(`editor "${filePath}"`)
} catch {
console.log(
`Failed to open file, please open ${c.gray(filePath)} manually.`
`Failed to open file, please open ${c.gray(filePath)} manually.`,
)
process.exit(-1)
}
Expand Down
6 changes: 3 additions & 3 deletions nrmrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function resolveUrl(url) {
export async function appendNrmrc(name, url) {
return await appendFile(
nrmrcPath,
`[${encodeName(name)}]\nregistry=${resolveUrl(url)}\n\n`
`[${encodeName(name)}]\nregistry=${resolveUrl(url)}\n\n`,
)
}

Expand All @@ -95,8 +95,8 @@ export async function writeNrmrc(registries) {
Array.from(registries.entries())
.map(
([name, url]) =>
`[${encodeName(name)}]\nregistry=${resolveUrl(url)}`
`[${encodeName(name)}]\nregistry=${resolveUrl(url)}`,
)
.join('\n\n')
.join('\n\n'),
)
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"nrml": "cli.mjs"
},
"devDependencies": {
"@types/node": "^22.2.0",
"@types/node": "^22.4.0",
"typescript": "^5.5.4"
},
"publishConfig": {
Expand Down
10 changes: 5 additions & 5 deletions registry.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import { getRegistryFromStream } from './registry.mjs'
test('getRegistryFromStream()', async () => {
assert.deepStrictEqual(
await getRegistryFromStream(Readable.from('')),
undefined
undefined,
)

assert.deepStrictEqual(
await getRegistryFromStream(
Readable.from(`registry=https://registry.npmmirror.com/`)
Readable.from(`registry=https://registry.npmmirror.com/`),
),
'https://registry.npmmirror.com/'
'https://registry.npmmirror.com/',
)

assert.deepStrictEqual(
await getRegistryFromStream(
Readable.from(`//registry.npmjs.org/:_authToken=npm_123456
# strict-ssl=false
registry= https://registry.npmmirror.com/`)
registry= https://registry.npmmirror.com/`),
),
'https://registry.npmmirror.com/'
'https://registry.npmmirror.com/',
)
})
6 changes: 3 additions & 3 deletions utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default c
export async function printRegistries(
currentRegistryUrl,
registriesInfo,
timeoutLimit
timeoutLimit,
) {
const registries = await getAllRegistries()
registriesInfo ||= Array.from(registries.entries()).map(([name, url]) => ({
Expand All @@ -61,7 +61,7 @@ export async function printRegistries(
}))

const maxNameLength = Math.max(
...registriesInfo.map(({ name }) => name.length)
...registriesInfo.map(({ name }) => name.length),
)
/**
* @type {number=}
Expand All @@ -73,7 +73,7 @@ export async function printRegistries(
// lazy compute
if (!maxUrlLength)
maxUrlLength = Math.max(
...registriesInfo.map(({ url }) => url.length)
...registriesInfo.map(({ url }) => url.length),
)
}

Expand Down

0 comments on commit 2996a3e

Please sign in to comment.