Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

liftoff

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

liftoff - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

61

index.js

@@ -9,3 +9,2 @@ var util = require('util');

var isPlainObject = require('is-plain-object').isPlainObject;
var mapValues = require('object.map');
var fined = require('fined');

@@ -24,2 +23,6 @@

function isString(val) {
return typeof val === 'string';
}
function Liftoff(opts) {

@@ -55,2 +58,4 @@ EE.call(this);

var searchPaths = this.searchPaths.slice();
// store the instance configName to use in closures without access to `this`
var configName = this.configName;

@@ -66,3 +71,3 @@ // calculate current cwd

if (!found) {
return;
return null;
}

@@ -120,2 +125,11 @@ if (isPlainObject(found.extension)) {

}
// resolve something like `{ gulpfile: "./abc.xyz" }` to the absolute path
// based on the path of the configFile
if (Object.prototype.hasOwnProperty.call(configFile, configName)) {
if (isString(configFile[configName])) {
configFile[configName] = path.resolve(path.dirname(configFilePath), configFile[configName]);
}
}
visited[configFilePath] = true;

@@ -132,16 +146,12 @@ if (configFile && configFile.extends) {

var configFiles = {};
if (isPlainObject(this.configFiles)) {
configFiles = mapValues(this.configFiles, function (searchPaths, fileStem) {
var defaultObj = { name: fileStem, cwd: cwd, extensions: exts };
var configFiles = [];
if (Array.isArray(this.configFiles)) {
configFiles = this.configFiles.map(function (pathObj) {
var defaultObj = { cwd: cwd, extensions: exts };
var foundPath = arrayFind(searchPaths, function (pathObj) {
return findAndRegisterLoader(pathObj, defaultObj);
});
return foundPath;
return findAndRegisterLoader(pathObj, defaultObj);
});
}
var config = mapValues(configFiles, function (startingLocation) {
var config = configFiles.map(function (startingLocation) {
var defaultConfig = {};

@@ -155,2 +165,23 @@ if (!startingLocation) {

var configPathOverride = arrayFind(config, function (cfg) {
if (Object.prototype.hasOwnProperty.call(cfg, configName)) {
if (isString(cfg[configName])) {
return cfg[configName];
}
}
});
var additionPreloads = arrayFind(config, function (cfg) {
if (Object.prototype.hasOwnProperty.call(cfg, 'preload')) {
if (Array.isArray(cfg.preload)) {
if (cfg.preload.every(isString)) {
return cfg.preload;
}
}
if (isString(cfg.preload)) {
return cfg.preload;
}
}
});
// if cwd was provided explicitly, only use it for searching config

@@ -166,3 +197,3 @@ if (opts.cwd) {

var configNameSearch = buildConfigName({
configName: this.configName,
configName: configName,
extensions: Object.keys(this.extensions),

@@ -175,3 +206,3 @@ });

searchPaths: searchPaths,
configPath: opts.configPath,
configPath: opts.configPath || configPathOverride,
});

@@ -225,3 +256,3 @@

cwd: cwd,
preload: preload,
preload: preload.concat(additionPreloads || []),
completion: opts.completion,

@@ -228,0 +259,0 @@ configNameSearch: configNameSearch,

{
"name": "liftoff",
"version": "4.0.0",
"version": "5.0.0",
"description": "Launch your command line tool with ease.",

@@ -33,3 +33,2 @@ "author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",

"is-plain-object": "^5.0.0",
"object.map": "^1.0.1",
"rechoir": "^0.8.0",

@@ -36,0 +35,0 @@ "resolve": "^1.20.0"

@@ -166,7 +166,9 @@ <p align="center">

An object of configuration files to find. Each property is keyed by the default basename of the file being found, and the value is an object of [path arguments](#path-arguments) keyed by unique names.
An array of configuration files to find with each value being a [path arguments](#path-arguments).
The order of the array indicates the priority that config file overrides are applied. See [Config Files](#config-files) for the config file specification and description of overrides.
**Note:** This option is useful if, for example, you want to support an `.apprc` file in addition to an `appfile.js`. If you only need a single configuration file, you probably don't need this. In addition to letting you find multiple files, this option allows more fine-grained control over how configuration files are located.
Type: `Object`
Type: `Array`

@@ -225,7 +227,5 @@ Default: `null`

name: 'hacker',
configFiles: {
'.hacker': {
cwd: '.',
},
},
configFiles: [
{ name: '.hacker', path: '.' }
],
});

@@ -239,12 +239,11 @@ ```

name: 'hacker',
configFiles: {
'.hacker': {
home: {
path: '~',
extensions: {
rc: null,
},
configFiles: [
{
name: '.hacker',
path: '~',
extensions: {
rc: null,
},
},
},
],
});

@@ -258,29 +257,12 @@ ```

name: 'hacker',
configFiles: {
'.hacker': {
up: {
path: '.',
findUp: true,
},
configFiles: [
{
name: '.hacker',
path: '.',
findUp: true,
},
},
],
});
```
In this example, the `name` is overridden and the key is ignored so Liftoff looks for `.override.js`.
```js
const MyApp = new Liftoff({
name: 'hacker',
configFiles: {
hacker: {
override: {
path: '.',
name: '.override',
},
},
},
});
```
In this example, Liftoff will use the home directory as the `cwd` and looks for `~/.hacker.js`.

@@ -291,10 +273,9 @@

name: 'hacker',
configFiles: {
'.hacker': {
home: {
path: '.',
cwd: '~',
},
configFiles: [
{
name: '.hacker',
path: '.',
cwd: '~',
},
},
],
});

@@ -338,7 +319,5 @@ ```

name: 'hacker',
configFiles: {
'.hacker': {
home: { path: '.', cwd: '~' },
},
},
configFiles: [
{ name: '.hacker', path: '.', cwd: '~' }
],
});

@@ -349,19 +328,4 @@ const onExecute = function (env, argv) {

const onPrepare = function (env) {
env.configProps = ['home', 'cwd']
.map(function (dirname) {
return env.configFiles['.hacker'][dirname];
})
.filter(function (filePath) {
return Boolean(filePath);
})
.reduce(function (config, filePath) {
return mergeDeep(config, require(filePath));
}, {});
if (env.configProps.hackerfile) {
env.configPath = path.resolve(env.configProps.hackerfile);
env.configBase = path.dirname(env.configPath);
}
Hacker.execute(env, onExecute);
const config = env.config['.hacker'];
Hacker.execute(env, config.forcedFlags, onExecute);
};

@@ -481,3 +445,4 @@ Hacker.prepare({}, onPrepare);

- `modulePackage`: the contents of the local module's package.json (if found)
- `configFiles`: an object of filepaths for each found config file (filepath values will be null if not found)
- `configFiles`: an array of filepaths for each found config file (filepath values will be null if not found)
- `config`: an array of loaded config objects in the same order as `configFiles`

@@ -517,3 +482,4 @@ ### execute(env, [forcedFlags], callback(env, argv))

- `modulePackage`: the contents of the local module's package.json (if found)
- `configFiles`: an object of filepaths for each found config file (filepath values will be null if not found)
- `configFiles`: an array of filepaths for each found config file (filepath values will be null if not found)
- `config`: an array of loaded config objects in the same order as `configFiles`

@@ -609,2 +575,18 @@ ### events

## Config files
Liftoff supports a small definition of config files, but all details provided by users will be available in `env.config`.
### `extends`
All `extends` properties will be traversed and become the basis for the resulting config object. Any path provided for `extends` will be loaded with node's `require`, so all extensions and loaders supported on the Liftoff instance will be available to them.
### Field matching the `configName`
Users can override the `configPath` via their config files by specifying a field with the same name as the primary `configName`. For example, the `hackerfile` property in a `configFile` will resolve the `configPath` and `configBase` against the path.
### `preload`
If specified as a string or array of strings, they will be added to the list of preloads in the environment.
## Examples

@@ -611,0 +593,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc