Skip to content

Commit 3dd855d

Browse files
committed
feat:hooks
1 parent 55b18e3 commit 3dd855d

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

content/guide/nativescript-hooks-guide.md renamed to content/guide/hooks.md

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ To add hooks to your plugin, follow these steps:
174174

175175
**1. Install the Hook Module**
176176

177-
```bash
178-
npm install nativescript-hook --save
179-
```
180-
181-
For NativeScript 7+, use:
182-
183177
```bash
184178
npm install @nativescript/hook --save
185179
```
@@ -189,23 +183,15 @@ npm install @nativescript/hook --save
189183
Create `postinstall.js` at the root folder of your plugin:
190184

191185
```javascript
192-
var hook = require('nativescript-hook')(__dirname)
193-
hook.postinstall()
194-
195-
// For NativeScript 7+:
196-
// require('@nativescript/hook')(__dirname).postinstall();
186+
require('@nativescript/hook')(__dirname).postinstall();
197187
```
198188

199189
**3. Create preuninstall.js**
200190

201191
Create `preuninstall.js` at the root folder of your plugin:
202192

203193
```javascript
204-
var hook = require('nativescript-hook')(__dirname)
205-
hook.preuninstall()
206-
207-
// For NativeScript 7+:
208-
// require('@nativescript/hook')(__dirname).preuninstall();
194+
require('@nativescript/hook')(__dirname).preuninstall();
209195
```
210196

211197
**4. Update package.json Scripts**
@@ -235,8 +221,7 @@ Define your hooks under the `nativescript` property:
235221
},
236222
{
237223
"type": "after-prepare",
238-
"script": "lib/after-prepare.js",
239-
"inject": true
224+
"script": "lib/after-prepare.js"
240225
}
241226
]
242227
}
@@ -253,10 +238,6 @@ Specifies when the hook should execute. Format: `before-<hookName>` or `after-<h
253238

254239
The relative path from the plugin root to the hook implementation file.
255240

256-
#### inject (Optional)
257-
258-
Boolean property indicating whether the hook should be executed in-process (`true`) or spawned (`false`). When `inject: true`, the hook can access NativeScript CLI services.
259-
260241
#### name (Optional)
261242

262243
Custom name for the hook. Defaults to the plugin package name.

content/sidebar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export default [
314314
},
315315
{
316316
text: 'Hooks',
317-
link: '/guide/nativescript-hooks-guide',
317+
link: '/guide/hooks',
318318
},
319319
{
320320
text: 'Platform Version Handling',

0 commit comments

Comments
 (0)