File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
website/docs/guides/task-types/other-tasks Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { processScript } from '../utils/processScript';
3
3
import {
4
4
ModStep ,
5
5
ScriptTaskType ,
6
- TaskContext ,
6
+ ModuleContext ,
7
7
TaskName ,
8
8
} from '../types/mod.types' ;
9
9
import { checkCondition } from '../utils/checkCondition' ;
@@ -61,7 +61,7 @@ export async function scriptTask(args: {
61
61
set : function ( variable : string , value : any ) : void {
62
62
variables . set ( variable , value ) ;
63
63
} ,
64
- } as TaskContext
64
+ } as ModuleContext
65
65
) ;
66
66
let resultValue : any ;
67
67
if ( 'script' in action ) {
@@ -79,8 +79,10 @@ export async function scriptTask(args: {
79
79
__dirname ,
80
80
path . join ( path . dirname ( args . configPath ) , action . module )
81
81
)
82
- ) as ( ctx : any ) => any ;
83
- resultValue = await plugin ( ctx ) ;
82
+ ) as ( ( ctx : any ) => any ) | { default : ( ctx : any ) => any } ;
83
+ if ( 'default' in plugin ) {
84
+ resultValue = await plugin . default ( ctx ) ;
85
+ } else resultValue = await plugin ( ctx ) ;
84
86
}
85
87
if ( action . name && resultValue != null )
86
88
variables . set ( action . name , resultValue ) ;
Original file line number Diff line number Diff line change @@ -565,7 +565,7 @@ export type PackageJsonType = {
565
565
} & Record < string , any > ;
566
566
567
567
export type TaskName = keyof typeof taskList ;
568
- export type TaskContext = {
568
+ export type ModuleContext = {
569
569
[ K in TaskName ] : (
570
570
action :
571
571
| Extract < ModStep , { task : K } > [ 'actions' ] [ number ]
Original file line number Diff line number Diff line change @@ -82,15 +82,15 @@ module.exports = async function integrate(ctx) {
82
82
83
83
# ## Typescript
84
84
85
- You can add `react-native-integrate` as dev dependency and use `TaskContext ` type for TS.
85
+ You can add `react-native-integrate` as dev dependency and use `ModuleContext ` type for TS.
86
86
Note that you need to transpile your plugin to CommonJS before shipping.
87
87
88
88
_plugin/integrate.ts_
89
89
90
90
` ` ` js
91
- import { TaskContext } from "react-native-integrate";
91
+ import { ModuleContext } from "react-native-integrate";
92
92
93
- module.exports = async function integrate(ctx: TaskContext ) {
93
+ export default async function integrate(ctx: ModuleContext ) {
94
94
await ctx.app_delegate({
95
95
prepend: 'some import'
96
96
});
You can’t perform that action at this time.
0 commit comments