mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-26 19:12:12 -04:00
A new property called `skipped` added to `node_modules/.modules.yaml`. The property is an array of package IDs, of those packages that are optional an were skipped during installation. Close #681
31 lines
897 B
TypeScript
31 lines
897 B
TypeScript
import path = require('path')
|
|
import loadYamlFile = require('load-yaml-file')
|
|
import writeYamlFile = require('write-yaml-file')
|
|
|
|
// The dot prefix is needed because otherwise `npm shrinkwrap`
|
|
// thinks that it is an extraneous package.
|
|
const modulesFileName = '.modules.yaml'
|
|
|
|
export type Modules = {
|
|
packageManager: string,
|
|
storePath: string,
|
|
skipped: string[],
|
|
}
|
|
|
|
export async function read (modulesPath: string): Promise<Modules | null> {
|
|
const modulesYamlPath = path.join(modulesPath, modulesFileName)
|
|
try {
|
|
return await loadYamlFile<Modules>(modulesYamlPath)
|
|
} catch (err) {
|
|
if ((<NodeJS.ErrnoException>err).code !== 'ENOENT') {
|
|
throw err
|
|
}
|
|
return null
|
|
}
|
|
}
|
|
|
|
export function save (modulesPath: string, modules: Modules) {
|
|
const modulesYamlPath = path.join(modulesPath, modulesFileName)
|
|
return writeYamlFile(modulesYamlPath, modules, {sortKeys: true})
|
|
}
|