Clean 命令

clean命令是清理 Serverless Devs 的缓存相关功能,可以通过该命令清理环境、不用的依赖包以及相关的缓存内容。

命令解析

当我们执行s clean -h之后,可以进行相关帮助信息的查看:

$ s clean -h
Usage: s cli [options]

Clean up the cache related functions of serverless devs. You can clean up the environment, unused dependent packages and related cache contents through this command.
    
    Example:
        $ s clean --component fc-api
        $ s clean --all

    Tips:
        Get all installed component: s component

📖 Document: https://github.com/Serverless-Devs/Serverless-Devs/tree/master/docs/zh/command/clean.md

Options:
  --all                         Clean up the environment
  --cache [dirName]             Delete the <dirName> file in the cache
  --component [componentName]   Remove component (like: fc, fc@0.0.1)
  -h, --help                    Display help for command

参数解析

参数全称参数缩写是否必填参数含义
all选填清理环境
cache选填删除缓存里的的文件
component选填删除指定的组件,可以是组件名,也可以是[组件名@版本号]

操作案例

如果想要清理掉某个组件,可以通过--component参数与具体的组件名进行清理,例如:

$ s clean --component fc-api
Component [fc-api] has been cleaned up successfully.

如果想要清理整体环境,可以直接通过--all参数进行,例如:

$ s clean --all       
The environment of Serverless Devs has been cleaned up successfully.

注意事项

在进行指定组件的清理时,系统会按照指定的逻辑进行组件的清理:

  1. 系统先会确定当前设置的 Registry 缓存中,存在的符合条件的组件,并进行清理;
  2. 系统将会对系统的最终 Registry 缓存中(Github Registry),存在的符合条件的组件,并进行清理;
在 GitHub 上编辑本页面 更新时间: Wed, May 10, 2023