NodeUtils
Import :
const NodeUtils = brackets.getModule("utils/NodeUtils")
isNodeReady ⇒ boolean
checks if Node connector is ready
Kind: global variable
Returns: boolean - returns true if it's ready, otherwise false
Strings
Generic node util APIs connector. see src-node/utils.js for node peer
Kind: global constant
fetchURLText(url, encoding) ⇒ Promise.<string>
Fetches text content from a URL This is only available in the native app
Kind: global function
| Param | Type |
|---|---|
| url | string |
| encoding | string |
getPhoenixBinaryVersion() ⇒ Promise.<string>
Gets the version of the Phoenix binary This is only available in the native app
Kind: global function
getLinuxOSFlavorName() ⇒ Promise.<(string|null)>
Retrieves the Linux OS flavor name This is only available in the native app on Linux
Kind: global function
openUrlInBrowser(url, browserName)
Opens a URL in the default browser. This is only available in the native app.
Kind: global function
| Param | Type |
|---|---|
| url | string |
| browserName | string |
_npmInstallInFolder(moduleNativeDir) ⇒ CancellablePromise
Runs the bundled npm install in the given folder. Rejects if an install is already in progress there (two npm processes on one node_modules corrupt each other).
The returned promise carries a cancel() method - cancellation is only meaningful for
the specific install you started, so it lives on the handle rather than as a module API.
Cancelling kills the npm process; the promise then rejects with a "cancelled" error.
Kind: global function
| Param | Type | Description |
|---|---|---|
| moduleNativeDir | string | platform path of the folder holding package.json |
downloadFile(url, destFile, [options]) ⇒ CancellablePromise
Downloads a URL to a file on disk, fully node-side (native fetch, streamed to disk). When an expected sha256 is given, a mismatch deletes the file and rejects - a resolved promise means the file holds exactly the pinned bytes. This is only available in the native app.
Kind: global function
Returns: CancellablePromise - the returned promise carries a cancel() method that aborts
the download mid-stream - the promise then rejects with a "cancelled" error and the
partial file is deleted
| Param | Type | Description |
|---|---|---|
| url | string | download URL (redirects followed) |
| destFile | string | platform path to write (parent directories created) |
| [options] | Object | |
| [options.sha256] | string | expected hex digest of the downloaded bytes |
| [options.progress] | function | called with (transferredBytes, totalBytes) as the download advances; totalBytes is 0 if the server sent no length |
extractZipFile(zipPath, destDir) ⇒ Promise.<void>
Extracts a zip file into a directory node-side (stdlib only, no browser JSZip; creates the directory if missing, restores unix executable bits recorded in the archive). Python wheels are plain zips, so this installs those too. This is only available in the native app.
Kind: global function
| Param | Type | Description |
|---|---|---|
| zipPath | string | platform path of the zip file |
| destDir | string | platform path of the directory to extract into |
setExecutableBits(filePath) ⇒ Promise.<void>
Marks a file as executable (chmod 755); no-op on Windows. For binaries whose archives did not carry unix mode bits. This is only available in the native app.
Kind: global function
| Param | Type | Description |
|---|---|---|
| filePath | string | platform path of the file |
execFileWithInput(command, [args], [options]) ⇒ Promise.<ExecFileResult>
Runs an executable with the given args, feeding it text on stdin and capturing its output -
a one-shot filter-style invocation (e.g. ruff format - for the Python beautifier). No
shell is involved. Resolves with the exit code rather than rejecting on non-zero, so
callers can read stderr for the reason.
This is only available in the native app.
Kind: global function
| Param | Type | Description |
|---|---|---|
| command | string | platform path of the executable (or a PATH command name) |
| [args] | Array.<string> | |
| [options] | Object | |
| [options.stdinText] | string | written to the process's stdin, then closed |
| [options.cwd] | string | working directory |
| [options.timeoutMs] | number | kill the process and reject after this long |
getEnvironmentVariable(varName) ⇒ Promise.<string>
Gets an environment variable's value This is only available in the native app
Kind: global function
| Param | Type |
|---|---|
| varName | string |
ESLintFile(text, fullFilePath, projectFullPath)
Runs ESLint on a file This is only available in the native app
Kind: global function
| Param | Type |
|---|---|
| text | string |
| fullFilePath | string |
| projectFullPath | string |
openNativeTerminal(cwd, [usePowerShell])
Runs ESLint on a file This is only available in the native app
Kind: global function
| Param | Type | Default | Description |
|---|---|---|---|
| cwd | string | the working directory of terminal | |
| [usePowerShell] | boolean | false |
openInDefaultApp(fullPath) ⇒ Promise.<void>
Opens a file in the default application for its type on Windows, macOS, and Linux.
Kind: global function
Returns: Promise.<void> - - Resolves if the file/folder is opened successfully, rejects otherwise.
| Param | Type | Description |
|---|---|---|
| fullPath | string | The path to the file/folder to open. |
getDeviceID() ⇒ Promise.<(string|null)>
gets the os device id. this usually won't change till os reinstall.
Kind: global function
Returns: Promise.<(string|null)> - - Resolves with the os identifier or null
Throws:
Error- If called from the browser
addDeviceLicenseSystemWide() ⇒ Promise.<boolean>
Enables device license by creating a system-wide license file. On Windows, macOS, and Linux this will request elevation if needed.
Kind: global function
Returns: Promise.<boolean> - - Resolves true if system wide defile file added, else false.
Throws:
Error- If called from the browser
removeDeviceLicenseSystemWide() ⇒ Promise.<boolean>
Removes the system-wide device license file. On Windows, macOS, and Linux this will request elevation if needed.
Kind: global function
Returns: Promise.<boolean> - - Resolves true if system wide defile file removed, else false.
Throws:
Error- If called from the browser
isLicensedDeviceSystemWide() ⇒ Promise.<boolean>
Checks if the current machine is configured to check for system-wide device license for all users at app start.
This validates that the system-wide license file exists, contains valid JSON, and has licensedDevice: true.
Kind: global function
Returns: Promise.<boolean> - - Resolves with true if the device is licensed, false otherwise.
getOSUserName() ⇒ Promise.<string>
Retrieves the operating system username of the current user. This method is only available in native apps.
Kind: global function
Returns: Promise.<string> - A promise that resolves to the OS username of the current user.
Throws:
ErrorThrows an error if called in a browser environment.
getSystemSettingsDir() ⇒ Promise.<string>
Retrieves the directory path for system settings. This method is applicable to native apps only.
Kind: global function
Returns: Promise.<string> - A promise that resolves to the path of the system settings directory.
Throws:
ErrorIf the method is called in browser app.
CancellablePromise : Promise
A Promise that additionally carries a cancel() method aborting the underlying
operation - the promise then rejects with a "cancelled" error.
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| cancel | function | aborts the in-flight operation |
ExecFileResult : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| code | number | the process's exit code |
| stdout | string | |
| stderr | string |