#
概念¥Concepts
以下概念是理解 API 文档的先决条件。它们将在全文中被引用,请参阅此页面以获取详细说明。
¥The following concepts are prerequisites to understanding the API docs. They will be referenced throughout, refer back to this page for detailed explanations.
如果你是新来的,请从 入门指南 开始。
¥If you're new here, begin with the Getting Started Guide.
#
VinylVinyl 是描述文件的元数据对象。Vinyl 实例的主要属性是 path
和 contents
- 文件系统上文件的核心方面。Vinyl 对象可用于描述来自多种来源的文件 - 在本地文件系统或任何远程存储选项上。
¥Vinyl is a metadata object that describes a file. The main properties of a Vinyl instance are path
and contents
- core aspects of a file on your file system. Vinyl objects can be used to describe files from many sources - on a local file system or any remote storage option.
#
Vinyl 适配器¥Vinyl adapters
虽然 Vinyl 提供了一种描述文件的方法,但仍然需要一种访问这些文件的方法。每个文件源都使用 Vinyl 适配器进行访问。
¥While Vinyl provides a way to describe a file, a way to access these files is needed. Each file source is accessed using a Vinyl adapter.
适配器公开:
¥An adapter exposes:
具有签名
src(globs, [options])
的方法并返回生成 Vinyl 对象的流。¥A method with the signature
src(globs, [options])
and returns a stream that produces Vinyl objects.具有签名
dest(folder, [options])
的方法并返回消耗 Vinyl 对象的流。¥A method with the signature
dest(folder, [options])
and returns a stream that consumes Vinyl objects.特定于其输入/输出介质的任何额外方法 - 比如
vinyl-fs
提供的symlink
方法。它们应该始终返回生成和/或消耗 Vinyl 对象的流。¥Any extra methods specific to their input/output medium - such as the
symlink
methodvinyl-fs
provides. They should always return streams that produce and/or consume Vinyl objects.
#
任务¥Tasks
每个 gulp 任务都是一个异步 JavaScript 函数,它要么接受错误优先回调,要么返回流、promise、事件触发器、子进程或可观察对象。由于某些平台限制,不支持同步任务。
¥Each gulp task is an asynchronous JavaScript function that either accepts an error-first callback or returns a stream, promise, event emitter, child process, or observable. Due to some platform limitations, synchronous tasks aren't supported.
更详细的解释请参见 创建任务。
¥For a more detailed explanation, see Creating Tasks.
#
通配符¥Globs
glob 是一串字面量和/或通配符,例如 *
、**
或 !
,用于匹配文件路径。通配符是使用一个或多个通配符在文件系统上定位文件的行为。
¥A glob is a string of literal and/or wildcard characters, like *
, **
, or !
, used to match filepaths. Globbing is the act of locating files on a file system using one or more globs.
如果你没有使用 glob 的经验,请参阅 解释通配符。
¥If you don't have experience with globs, see Explaining Globs.
#
通配符基础¥Glob base
全局基础 - 有时称为全局父级 - 是 glob 字符串中任何特殊字符之前的路径段。因此,/src/js/**.js
的全局基是 /src/js/
。保证所有与 glob 匹配的路径共享 glob 基址 - 该路径段不能是可变的。
¥A glob base - sometimes called glob parent - is the path segment before any special characters in a glob string. As such, the glob base of /src/js/**.js
is /src/js/
. All paths that match the glob are guaranteed to share the glob base - that path segment can't be variable.
由 src()
生成的 Vinyl 实例是使用 glob 基集作为其 base
属性来构造的。当使用 dest()
写入文件系统时,base
将从输出路径中删除以保留目录结构。
¥Vinyl instances generated by src()
are constructed with the glob base set as their base
property. When written to the file system with dest()
, the base
will be removed from the output path to preserve directory structures.
有关更深入的信息,请参阅 glob-parent 存储库。
¥For more in depth information, see the glob-parent repository.
#
文件系统统计¥File system stats
文件元数据作为 Node 的 fs.Stats
实例提供。它可用作 Vinyl 实例上的 stat
属性,并在内部用于确定 Vinyl 对象是否表示目录或符号链接。当写入文件系统时,权限和时间值将从 Vinyl 对象的 stat
属性同步。
¥File metadata is provided as an instance of Node's fs.Stats
. It is available as the stat
property on your Vinyl instances and used internally to determine if a Vinyl object represents a directory or symbolic link. When written to the file system, permissions and time values are synchronized from the Vinyl object's stat
property.
#
文件系统模式¥File system modes
文件系统模式决定文件存在哪些权限。文件系统上的大多数文件和目录都具有相当宽松的模式,允许 gulp 代表你读取/写入/更新文件。默认情况下,gulp 将创建与正在运行的进程具有相同权限的文件,但你可以通过 src()
、dest()
等中的选项配置模式。如果你遇到权限 (EPERM) 问题,请检查文件的模式。
¥File system modes determine what permissions exist for a file. Most files and directories on your file system will have a fairly permissive mode, allowing gulp to read/write/update files on your behalf. By default, gulp will create files with the same permissions as the running process, but you can configure the modes through options in src()
, dest()
, etc. If you're experiencing permission (EPERM) issues, check the modes on your files.
#
模块¥Modules
Gulp 由许多小模块组成,这些模块组合在一起可以协同工作。通过在小模块中利用 semver,我们可以发布错误修复和功能,而无需发布新版本的 gulp。通常,当你在主存储库上看不到进展时,工作正在这些模块之一中完成。
¥Gulp is made up of many small modules that are pulled together to work cohesively. By utilizing semver within the small modules, we can release bug fixes and features without publishing new versions of gulp. Often, when you don't see progress on the main repository, work is being done in one of these modules.
如果你遇到问题,请确保使用 npm update
命令更新当前模块。如果问题仍然存在,请在单个项目存储库上提出问题。
¥If you're having trouble, ensure your current modules are updated using the npm update
command. If the problem persists, open an issue on the individual project repository.
undertaker - 任务注册系统
¥undertaker - the task registration system
vinyl - 虚拟文件对象
¥vinyl - the virtual file objects
vinyl-fs - 本地文件系统的 vinyl 适配器
¥vinyl-fs - a vinyl adapter to your local file system
glob-watcher - 文件监视器
¥glob-watcher - the file watcher
bach - 使用
series()
和parallel()
进行任务编排¥bach - task orchestration using
series()
andparallel()
last-run - 跟踪任务的上次运行时间
¥last-run - tracks the last run time of a task
vinyl-sourcemap - 内置源映射支持
¥vinyl-sourcemap - built-in sourcemap support
gulp-cli - 与 gulp 交互的命令行接口
¥gulp-cli - the command line interface for interacting with gulp