Skip to content

Commit

Permalink
docs: improve doc string of run function
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 committed Aug 2, 2024
1 parent e720067 commit ea089ab
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-owls-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'archons': patch
---

Improve doc string of `run` function
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
/* auto-generated by NAPI-RS */

export declare function defineCommand(options: Command): Command
/**
* Run command
*
* **NOTE**: If the given `args` is empty, it will use `process.argv` instead.
*
* **NOTE**: The given `args` should include the nodejs executable and script name.
* For example, if you are running a script `index.js` in the current directory with
* a flag `--foo`, you should pass `["node", "index.js", "--foo"]` as `args`.
*
* @param cmd Command object
* @param args Run with given arguments
* @returns {void}
*/
export declare function run(cmd: Command, args?: Array<string> | undefined | null): void
/**
* Command context
Expand Down
52 changes: 13 additions & 39 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ switch (platform) {
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(
join(__dirname, 'archons-napi.win32-x64-msvc.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.win32-x64-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.win32-x64-msvc.node')
Expand All @@ -76,9 +74,7 @@ switch (platform) {
}
break
case 'ia32':
localFileExisted = existsSync(
join(__dirname, 'archons-napi.win32-ia32-msvc.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.win32-ia32-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.win32-ia32-msvc.node')
Expand All @@ -90,9 +86,7 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'archons-napi.win32-arm64-msvc.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.win32-arm64-msvc.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.win32-arm64-msvc.node')
Expand Down Expand Up @@ -131,9 +125,7 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'archons-napi.darwin-arm64.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.darwin-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.darwin-arm64.node')
Expand Down Expand Up @@ -167,9 +159,7 @@ switch (platform) {
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-x64-musl.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-x64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-x64-musl.node')
Expand All @@ -180,9 +170,7 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-x64-gnu.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-x64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-x64-gnu.node')
Expand All @@ -196,9 +184,7 @@ switch (platform) {
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-arm64-musl.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-arm64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-arm64-musl.node')
Expand All @@ -209,9 +195,7 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-arm64-gnu.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-arm64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-arm64-gnu.node')
Expand All @@ -225,9 +209,7 @@ switch (platform) {
break
case 'arm':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-arm-musleabihf.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-arm-musleabihf.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-arm-musleabihf.node')
Expand All @@ -238,9 +220,7 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-arm-gnueabihf.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-arm-gnueabihf.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-arm-gnueabihf.node')
Expand All @@ -254,9 +234,7 @@ switch (platform) {
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-riscv64-musl.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-riscv64-musl.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-riscv64-musl.node')
Expand All @@ -267,9 +245,7 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-riscv64-gnu.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-riscv64-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-riscv64-gnu.node')
Expand All @@ -282,9 +258,7 @@ switch (platform) {
}
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'archons-napi.linux-s390x-gnu.node')
)
localFileExisted = existsSync(join(__dirname, 'archons-napi.linux-s390x-gnu.node'))
try {
if (localFileExisted) {
nativeBinding = require('./archons-napi.linux-s390x-gnu.node')
Expand Down
11 changes: 11 additions & 0 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ pub fn define_command(options: Command) -> Command {
options
}

/// Run command
///
/// **NOTE**: If the given `args` is empty, it will use `process.argv` instead.
///
/// **NOTE**: The given `args` should include the nodejs executable and script name.
/// For example, if you are running a script `index.js` in the current directory with
/// a flag `--foo`, you should pass `["node", "index.js", "--foo"]` as `args`.
///
/// @param cmd Command object
/// @param args Run with given arguments
/// @returns {void}
#[napi]
pub fn run(env: Env, cmd: Command, args: Option<Vec<String>>) -> Result<()> {
let raw_args = resolve_option_args(env, args)?;
Expand Down

0 comments on commit ea089ab

Please sign in to comment.