Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Hexo): add event emitter descriptor #5302

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
82 changes: 82 additions & 0 deletions lib/hexo/index.ts
Expand Up @@ -145,6 +145,88 @@ declare module 'module' {
_cache: any;
}

interface Hexo {

/**
* Emitted before deployment begins.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#deployBefore
*/
on(event: 'deployBefore', listener: (...args: any[]) => any): this;

/**
* Emitted after deployment begins.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#deployAfter
*/
on(event: 'deployAfter', listener: (...args: any[]) => any): this;

/**
* Emitted before Hexo exits.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#exit
*/
on(event: 'exit', listener: (...args: any[]) => any): this;

/**
* Emitted before generation begins.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#generateBefore
*/
on(event: 'generateBefore', listener: (...args: any[]) => any): this;

/**
* Emitted after generation finishes.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#generateAfter
*/
on(event: 'generateAfter', listener: (...args: any[]) => any): this;

/**
* Emitted after a new post has been created. This event returns the post data:
* @param event
* @param listener
* @link https://hexo.io/api/events.html#new
*/
on(event: 'new', listener: (post: { path: string; content: string; }) => any): this;

/**
* Emitted before processing begins. This event returns a path representing the root directory of the box.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#processBefore
*/
on(event: 'processBefore', listener: (...args: any[]) => any): this;

/**
* Emitted after processing finishes. This event returns a path representing the root directory of the box.
* @param event
* @param listener
* @link https://hexo.io/api/events.html#processAfter
*/
on(event: 'processAfter', listener: (...args: any[]) => any): this;

/**
* Emitted after initialization finishes.
* @param event
* @param listener
*/
on(event: 'ready', listener: (...args: any[]) => any): this;

/**
* undescripted on emit
* @param event
* @param listener
*/
on(event: string, listener: (...args: any[]) => any): any;
emit(event: string, ...args: any[]): any;
}

class Hexo extends EventEmitter {
public base_dir: string;
public public_dir: string;
Expand Down