# loopback-run

> Run Loopback model method through a single command in a non-interactive way.

Latest version **1.3.1** (published 2022-04-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install loopback-run
pnpm add loopback-run
yarn add loopback-run
bun add loopback-run
```

Provides the command `loopback-run`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2022-04-06 |
| First published | 2019-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | HugoPoi |
| Maintainers | hugopoi |
| Keywords | Loopback, cli, shell, runner |

## Links

- npm: https://www.npmjs.com/package/loopback-run
- Repository: https://riviere.monibrand.com/opensource/loopback-run
- npm.io page: https://npm.io/package/loopback-run

## Dependencies (6)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [gauge](https://npm.io/package/gauge.md) ^2.7.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.4
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [event-to-promise](https://npm.io/package/event-to-promise.md) ^0.8.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2022-04-06
- 1.3.0 — 2020-07-28
- 1.2.0 — 2020-07-24
- 1.1.2 — 2020-07-24
- 1.1.1 — 2019-10-04
- 1.1.0 — 2019-08-19
- 1.0.2 — 2019-08-07
- 1.0.1 — 2019-07-11
- 1.0.0 — 2019-05-24

## README

# Loopback-run

A tool to launch Loopback method with a single command in a non-interactive way.

A complementary tool of [Loopback-console](https://www.npmjs.com/package/loopback-console).

## Usage

In your loopback project

1. `npm install --save-dev loopback-run`
1. `npx loopback-run UserAccount.find`
1. `npx loopback-run UserAccount.create --username test --email test@localhost --password test123`


### Options

You can path all the options for loopback-run before a `--` if you need
to use options for the method itself

`npx loopback-run UserAccount.findOne --exit -- --where.username=test`

If you dont have method options you can do `npx loopback-run UserAccount.findOne --exit`


#### `--exit`
 Close all opened datasource and force exit
 Needed if you open persistent connection outside of loopback datasources
#### `--loopbackPath`
 Define a custom path for loopback entry point.

 You can use the environnement variable `LOOPBACK_PATH` as well.
#### `--argsFile`
  Provide a javascript file with exported options, will be merge with
  other options provided

#### `--json`
  All output will be serialize with `JSON.stringify`

#### `--argsAsJson`
  Parse a json string as args for the loopback method
  `npx loopback-run MyModel.task --argsAsJson '{"where": {"prop.subprod": "value"}}'`
### Progress

You can provide a `EventEmitter` in the promise to display progress

```javascript
const _ = require('lodash');
const Promise = require('bluebird');

SampleModel.task = function(){
  const eventEmitter = new EventEmitter();
  let done = 0;
  const promise = Promise.mapSeries(_.times(100), async () => {
     await Promise.delay(_.random(10, 500));
     eventEmitter.emit('progress', {done: ++done, total: 100});
  });
  promise.events = eventEmitter;
  return promise;
}
```

### Debug

`DEBUG=loopback-run npx loopback-run MyModel.task`

---
_Source: https://npm.io/package/loopback-run · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
