2022-10-11: Shell scripting with Node.js
- I About this book
- II Foundations
- III Core Node.js functionality
- 7 Working with file system paths and file URLs on Node.js
- 7.1 Path-related functionality on Node.js
- 7.2 Foundational path concepts and their API support
- 7.3 Getting the paths of standard directories via module
'node:os'
- 7.4 Concatenating paths
- 7.5 Ensuring paths are normalized, fully qualified, or relative
- 7.6 Parsing paths: extracting various parts of a path (filename extension etc.)
- 7.7 Categorizing paths
- 7.8
path.format()
: creating paths out of parts - 7.9 Using the same paths on different platforms
- 7.10 Using a library to match paths via globs
- 7.11 Using
file:
URLs to refer to files
- 8 Working with the file system on Node.js
- 8.1 Concepts, patterns and conventions of Node’s file system APIs
- 8.2 Reading and writing files
- 8.3 Handling line terminators across platforms
- 8.4 Traversing and creating directories
- 8.5 Copying, renaming, moving files or directories
- 8.6 Removing files or directories
- 8.7 Reading and changing file system entries
- 8.8 Working with links
- 8.9 Further reading
- 9 Native Node.js streams
- 10 Using web streams on Node.js
- 10.1 What are web streams?
- 10.2 Reading from ReadableStreams
- 10.3 Turning data sources into ReadableStreams via wrapping
- 10.4 Writing to WritableStreams
- 10.5 Turning data sinks into WritableStreams via wrapping
- 10.6 Using TransformStreams
- 10.7 Implementing custom TransformStreams
- 10.8 A closer look at backpressure
- 10.9 Byte streams
- 10.10 Node.js-specific helpers
- 10.11 Further reading
- 11 Stream recipes
- 12 Running shell commands in child processes
- 12.1 Overview of this chapter
- 12.2 Spawning processes asynchronously:
spawn()
- 12.3 Spawning processes synchronously:
spawnSync()
- 12.4 Asynchronous helper functions based on
spawn()
- 12.5 Synchronous helper functions based on
spawnAsync()
- 12.6 Useful libraries
- 12.7 Choosing between the functions of module
'node:child_process'
- 7 Working with file system paths and file URLs on Node.js
- IV Working with packages
- 13 Installing npm packages and running bin scripts
- 14 Creating cross-platform shell scripts
- 14.1 Required knowledge
- 14.2 Node.js ESM modules as standalone shell scripts on Unix
- 14.3 Creating an npm package with shell scripts
- 14.4 How npm installs shell scripts
- 14.5 Publishing the example package to the npm registry
- 14.6 Standalone Node.js shell scripts with arbitrary extensions on Unix
- 14.7 Standalone Node.js shell scripts on Windows
- 14.8 Creating native binaries for Linux, macOS, and Windows
- 14.9 Shell paths: making sure shells find scripts
- 15 Running cross-platform tasks via npm package scripts
- 15.1 npm package scripts
- 15.2 Kinds of package scripts
- 15.3 The shell environment in which package scripts are run
- 15.4 Using environment variables in package scripts
- 15.5 Arguments for package scripts
- 15.6 The npm log level (how much output is produced)
- 15.7 Cross-platform shell scripting
- 15.8 Helper packages for common operations
- 15.9 Expanding the capabilities of package scripts
- 15.10 Sources of this chapter
- V Handling common tasks in scripting