-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's to install project dependencies according to dev-package rules
- Loading branch information
Showing
6 changed files
with
91 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
|
||
const toPlainObject = require("es5-ext/object/normalize-options") | ||
, ensureString = require("es5-ext/object/validate-stringifiable-value") | ||
, ee = require("event-emitter") | ||
, unifyEmitters = require("event-emitter/unify") | ||
, { resolve } = require("path") | ||
, ensureConfiguration = require("./lib/private/ensure-user-configuration") | ||
, install = require("./lib/private/install"); | ||
|
||
module.exports = (path, configuration, options = {}) => { | ||
path = resolve(ensureString(path)); | ||
const progressData = ee({ done: new Set(), ongoingMap: new Map(), externalsMap: new Map() }); | ||
const promise = ee( | ||
install({ path }, ensureConfiguration(configuration), toPlainObject(options), progressData) | ||
); | ||
unifyEmitters(progressData, promise); | ||
return promise; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use strict"; | ||
|
||
const wait = require("timers-ext/promise/sleep") | ||
, cleanupNpmInstall = require("./cleanup-npm-install") | ||
, getPackageJson = require("./get-package-json") | ||
, removeNonDirectDependencies = require("./remove-non-direct-dependencies") | ||
, setupDependencies = require("./setup-dependencies"); | ||
|
||
module.exports = async (packageContext, userConfiguration, inputOptions, progressData) => { | ||
const { path } = packageContext; | ||
const { hooks } = userConfiguration; | ||
const packageJson = (packageContext.packageJson = getPackageJson(path)); | ||
if (!packageJson) return; | ||
const name = (packageContext.name = packageJson.name); | ||
|
||
// Ensure to emit "start" event in next event loop | ||
await wait(); | ||
progressData.emit("start", { name, type: "update" }); | ||
|
||
// Cleanup outcome of eventual previous npm crashes | ||
await cleanupNpmInstall(packageContext); | ||
|
||
await setupDependencies(packageContext, userConfiguration, inputOptions, progressData); | ||
|
||
if (hooks.afterPackageInstall) { | ||
await hooks.afterPackageInstall(packageContext, userConfiguration, inputOptions); | ||
} | ||
|
||
// Cleanup unexpected dependencies from node_modules | ||
await removeNonDirectDependencies(packageContext, userConfiguration); | ||
|
||
progressData.emit("end", { name }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters