diff --git a/.changeset/kind-owls-grab.md b/.changeset/kind-owls-grab.md new file mode 100644 index 0000000..b63a6e1 --- /dev/null +++ b/.changeset/kind-owls-grab.md @@ -0,0 +1,5 @@ +--- +'archons': patch +--- + +Improve doc string of `run` function diff --git a/index.d.ts b/index.d.ts index a749de1..df9f737 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 | undefined | null): void /** * Command context diff --git a/index.js b/index.js index 8185ddb..1d7ba2a 100644 --- a/index.js +++ b/index.js @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') @@ -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') diff --git a/src/command.rs b/src/command.rs index b46a928..8a34e88 100644 --- a/src/command.rs +++ b/src/command.rs @@ -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>) -> Result<()> { let raw_args = resolve_option_args(env, args)?;