npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yarn-tool/script-lifecycle

v2.0.14

Published

npm/yarn script lifecycle utility for handling pre/post script execution order / 處理 npm/yarn 腳本生命週期 pre/post 執行順序的工具

Readme

@yarn-tool/script-lifecycle

npm/yarn script lifecycle utility for handling pre/post script execution order 處理 npm/yarn 腳本生命週期 pre/post 執行順序的工具

NPM version License

Description / 描述

This module provides utilities for handling npm/yarn script lifecycle hooks. It helps determine the correct execution order of pre/post scripts for known lifecycle events.

此模組提供處理 npm/yarn 腳本生命週期鉤子的工具函式。 幫助確定已知生命週期事件的 pre/post 腳本正確執行順序。

Supported Lifecycle Events / 支援的生命週期事件

| Event | Description | |-------|-------------| | install | npm install lifecycle scripts | | pack | npm pack lifecycle scripts | | publish | npm publish lifecycle scripts |

Installation / 安裝

# Using yarn
yarn add @yarn-tool/script-lifecycle

# Using yarn-tool
yarn-tool add @yarn-tool/script-lifecycle

# Using yt (yarn-tool alias)
yt add @yarn-tool/script-lifecycle

# Using npm
npm install @yarn-tool/script-lifecycle

Usage / 使用方式

getLifecycleList(scriptName, includeSelf?, currentScriptOnly?)

Get the ordered list of lifecycle scripts for a given script name.

獲取指定腳本名稱的生命週期腳本有序列表。

import { getLifecycleList } from '@yarn-tool/script-lifecycle';

// Get all scripts for install lifecycle
const installScripts = getLifecycleList('install');
// Returns: ['preinstall', 'install', 'postinstall', 'prepublish', 'prepare', 'preshrinkwrap', 'shrinkwrap', 'postshrinkwrap']

// Get all scripts for pack lifecycle (pack itself is excluded)
const packScripts = getLifecycleList('pack');
// Returns: ['prepublish', 'prepare', 'prepack', 'postpack']

// Get all scripts for publish lifecycle
const publishScripts = getLifecycleList('publish');
// Returns: ['prepublish', 'prepare', 'prepublishOnly', 'prepack', 'postpack', 'publish', 'postpublish']

// For unknown scripts, generates default pre/post hooks
const buildScripts = getLifecycleList('build');
// Returns: ['prebuild', 'build', 'postbuild']

getLifecycle(scriptName, currentScriptOnly?)

Get the lifecycle configuration for any script name.

獲取任意腳本名稱的生命週期配置。

import { getLifecycle } from '@yarn-tool/script-lifecycle';

const installConfig = getLifecycle('install');
// Returns: { name: 'install', ignoreSelf: false, before: ['preinstall'], after: ['postinstall', ...] }

const buildConfig = getLifecycle('build');
// Returns: { name: 'build', ignoreSelf: false, before: ['prebuild'], after: ['postbuild'] }

isKnownLifecycleKey(scriptName)

Check if a script name is a known lifecycle key.

檢查腳本名稱是否為已知的生命週期鍵。

import { isKnownLifecycleKey } from '@yarn-tool/script-lifecycle';

isKnownLifecycleKey('install');  // true
isKnownLifecycleKey('publish');  // true
isKnownLifecycleKey('build');    // false

entryToList(entry, includeSelf?)

Convert a lifecycle entry to an ordered list of script names.

將生命週期配置項轉換為腳本名稱的有序列表。

import { entryToList } from '@yarn-tool/script-lifecycle';

const entry = {
  name: 'custom',
  ignoreSelf: false,
  before: ['precustom'],
  after: ['postcustom']
};

const list = entryToList(entry);
// Returns: ['precustom', 'custom', 'postcustom']

API Reference / API 參考

Functions

| Function | Description | |----------|-------------| | getLifecycleCore<K>(scriptName) | Get the core lifecycle configuration for a known lifecycle script | | getLifecycle<K>(scriptName, currentScriptOnly?) | Get the lifecycle configuration for any script name | | getLifecycleList<K>(scriptName, includeSelf?, currentScriptOnly?) | Get the ordered list of lifecycle scripts | | entryToList<K>(entry, includeSelf?) | Convert a lifecycle entry to an ordered list | | isKnownLifecycleKey<K>(scriptName) | Check if a script name is a known lifecycle key |

Types

| Type | Description | |------|-------------| | ILifecycleEntry<K> | Lifecycle entry configuration interface | | ILifecycleMapKeys | Keys of known lifecycle events ('install', 'pack', 'publish') | | ILifecycleMapEntry<K> | Lifecycle map entry type | | ILifecycleMap<K> | Lifecycle map type | | ILifecycleList<K> | Lifecycle script list type |

Related / 相關套件

License / 授權

ISC © bluelovers