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 { const modulesYamlPath = path.join(modulesPath, modulesFileName) try { return await loadYamlFile(modulesYamlPath) } catch (err) { if ((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}) }