Skip to content

Commit 916b17e

Browse files
docs: update PublicAPI for cleanupService
Add information in PublicAPI for cleanupService and its methods.
1 parent b97f5aa commit 916b17e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

PublicAPI.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ const tns = require("nativescript");
7070
* [deviceLog](#devicelog)
7171
* [previewQrCodeService](#previewqrcodeservice)
7272
* [getPlaygroundAppQrCode](#getplaygroundappqrcode)
73+
* [cleanupService](#cleanupservice)
74+
* [setCleanupLogFile](#setcleanuplogfile)
7375

7476
## Module projectService
7577

@@ -1487,6 +1489,31 @@ tns.previewQrCodeService.getPlaygroundAppQrCode()
14871489
});
14881490
```
14891491
1492+
## cleanupService
1493+
The `cleanupService` is used to handle actions that should be executed after CLI's process had exited. This is an internal service, that runs detached childProcess in which it executes CLI's cleanup actions once CLI is dead. As the process is detached, logs from it are not shown anywhere, so the service exposes a way to add log file in which the child process will write its logs.
1494+
1495+
### setCleanupLogFile
1496+
Defines the log file location where the child cleanup process will write its logs.
1497+
1498+
> NOTE: You must call this method immediately after requiring NativeScript CLI. In case you call it after the cleanup process had started, it will not use the passed log file.
1499+
1500+
* Definition
1501+
```TypeScript
1502+
/**
1503+
* Sets the file in which the cleanup process will write its logs.
1504+
* This method must be called before starting the cleanup process, i.e. when CLI is initialized.
1505+
* @param {string} filePath Path to file where the logs will be written. The logs are appended to the passed file.
1506+
* @returns {void}
1507+
*/
1508+
setCleanupLogFile(filePath: string): void;
1509+
```
1510+
1511+
* Usage
1512+
```JavaScript
1513+
const tns = require("nativescript");
1514+
tns.cleanupService.setCleanupLogFile("/Users/username/cleanup-logs.txt");
1515+
```
1516+
14901517
## How to add a new method to Public API
14911518
CLI is designed as command line tool and when it is used as a library, it does not give you access to all of the methods. This is mainly implementation detail. Most of the CLI's code is created to work in command line, not as a library, so before adding method to public API, most probably it will require some modification.
14921519
For example the `$options` injected module contains information about all `--` options passed on the terminal. When the CLI is used as a library, the options are not populated. Before adding method to public API, make sure its implementation does not rely on `$options`.

0 commit comments

Comments
 (0)