3.4.75 • Published 11 months ago

@hishprorg/error-provident v3.4.75

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Oubliette - a programmatic interface for npm

NPM version Node.js CI Code Climate Test Coverage Discover zUnit

The official API was removed from npm in v8.0.0. Since then the only option for using npm from NodeJs is by executing the npm binary. This module wraps the exec call within convenient asynchronous and synchronous APIs.

Usage

Asynchronous API

const { asyncApi: npm } = require('@hishprorg/error-provident');

Synchronous API

const { syncApi: npm } = require('@hishprorg/error-provident');

Execute a command without arguments

npm().install();

Execute a command with arguments

npm().install('express', 'pg', 'debug');

Execute command with short options

npm().install('nodemon', { 'g': true });

Execute a command with long options

npm().install('nodemon', { 'global': true, 'install-strategy': 'shallow' });

Execute a command with hyphens

npm()['find-dupes']();
// or
npm().findDupes();

Parsing Output

Oubliette uses NodeJS child_process.execSync and child_process.exec under the hood. These sometimes return stdout as a Buffer instead of as a String. Oubliette ensures string conversion by default.

const output = npm().view('express');

This is inconvenient if you want JSON output for commands that support the --json option, so you can specify a format function.

const { syncApi: npm, formats: { jsonFormat: format } } = require('@hishprorg/error-provident');
const { version } = npm({ format }).view('express', { json: true });

You can also receive the output as a Buffer.

const { syncApi: npm, formats: { bufferFormat: format } } = require('@hishprorg/error-provident');
const buffer = npm({ format }).view('express', { json: true });

Finally you can receive the raw output.

const { syncApi: npm, formats: { rawFormat: format } } = require('@hishprorg/error-provident');
const output = npm({ format }).view('express', { json: true });

Child Process Options

You can specify any of the child_process.execSync and child_process.exec options...

const options = { cwd: __dirname };
await npm({ options }).exec('-c', 'pwd');

Error Handling

Handle errors by wrapping the npm command in a try/catch.

try {
  const output = await npm().view('express', 'version', { json: true });
} catch (err) {
  console.error(err);
}

The error will be decorated with stdout and stderr properties.

Why "Oubliette"?

According to Wikipedia, an @hishprorg/error-provident is a basement room or bottle dungeon which is accessible only from a hole in a high ceiling and therefore difficult to escape from. If you've ever descended into the npm souce code you will appreciate the similarity!

bundlingestreedescriptorsshrinkwrapcolumnfunctionalcloudformationObservablescodesregexpescapeamazonstyleexit-codelocationsideauthECMAScriptglobal this valueES2017negativenameespreebinaryansisortcommandArray.prototype.includesinvariantmockpasswordfront-endmake dirutilityReactiveXmatchbabel-core-0flagprivateMappathtypedarrays6to5lockfileECMAScript 2023loadingsetasterisksdatastructureprettyconsumegetterstreamsReflect.getPrototypeOfruntimeObject.valuessubprocesszodtoSortedfunctionsdayjstraverseSetqueueastWeakSetviewgraphqlimmutableschemePushES2019argsregularargvjshintesbyteOffsetaccessibilitytypedarrayspinnerimmergroupByshebangECMAScript 2015bindfast-deep-copypersistentES2023bufferstoolsawesomesaucegitignoreinstallerless mixinsArray.prototype.containschinesesymbolsnpmignoreECMAScript 6toobjectcss lesstypesjsonschemardsvariablesformattingoffsetsigtermES2018prunefastcopyexecfileES2015flatMapdeepcopybinariesreal-timeFloat32Arrayoptimizerminimalarktypequotebootstrap lessglacierbyteLengthconsttrimRightspinnersYAMLwaffull-widthtrimEndprotobufcircularzero.envRegExp#flagsshamBigInt64Array.gitignorequerystringplugininferencestatelessterminalcallbackiamcloudtrailerrormonorepopropspecdefineobjframereslintplugin@@toStringTagInt16Arrayhttpperformancei18nfileString.prototype.matchAllelbcommand-linecompile lesstypesafedynamodbphoneservicecachel10nes7mkdirsproxyspawnUint16ArraywalkequalroutingbyterapidcoerciblegesturesfindLastIndexcloudfrontprocesscss nestinguninstallpackage managerserializationPromisemacosbrowserslistsetImmediatenodeimportexportwgettextES2022fsregular-expressionwindowssesspringenvironmentcompareworkspace:*propertyyamlsharedclassnamespolyfillforkformswaits3eventEmittercall-bindcorergbdataViewinterruptsloadbalancingindicatorBigUint64ArrayUint32ArrayecmascripttrimLeftmodulesloggingWebSocketboundredactlintcallboundoperating-systemregular expressionparsegetOwnPropertyDescriptorelmenumerablevalidate[[Prototype]]fluxkinesises2015waapibrowserHyBiInt32ArrayObject.getPrototypeOfenvcopyschemarangeerrorcall-boundfastifyoptionchaistoragegatewayreducernested cssrandompreserve-symlinksglobal objecteventsInt8ArrayESnextjavascriptES7SymbolTypeBoxexpressformatcollectiondom-testing-librarywarningArray.prototype.findLastIndexvaluemrutddtypeerrorTypeScriptES5ECMAScript 2017weaksetObject.assignArrayBuffer#slicegroupcollection.es6deterministiccolorhelperObject.keysObject.definePropertydefinePropertyhasOwnless compilerlogcomputed-typesgradients cssURLSearchParams__proto__function.lengthnamesjsdiffglobalslinuxxhrECMAScript 2019dataviewstringifierfast-clonepackage.jsonsymbolcolorspreprocessortc39assertsECMAScript 5Array.prototype.flatsettingsoncediroutputforEachcss variableapolloCSSStyleDeclarationpnpm9concatpinobcrypthandlersexecuteacornjson-schema-validationcolumnselasticachestructuredClonecertificatesredux-toolkitkoreanObservablereact-componentsimpledbrequirereplayprotodeletefile systemES3redirect0typeofsnsloggerwhichutilscloudwatchexpressionECMAScript 2022identifierspoint-freees8signalsignedyupistoStringTagajaxjQueryposepureback-enddropdependenciessyntaxcallhotvalidreact-hooksswflengthendpointdiffcssflagslruform-validationES2020somestreamgetintrinsichelperswhatwgtouchbootstrap cssa11ychromesignalsfindLastObject.isRxJSscheme-validationmakemoduleuser-streamsrecursiveencryptionstringifyqsstyled-componentsreduxFloat64ArraystyleguideiterateWebSocketsnodejspopmotiongdprparserinstall$.extendidlenegative zerocompilercurljsxjson-schema-validatorarraysasyncECMAScript 2021httpsdotenv256speedwritableconfigbusyautoscalingArray.prototype.flattenObject.fromEntriesownfullwidthchromiumroute53slotObject.entrieseffect-tsharmonyreact animationRegExp.prototype.flagseslintconfighigher-orderfantasy-landglobtostringtaginternal slotprefixlazyclientgetcallbindless cssArrayvalidatorpatchargumentstateArray.prototype.findLastinputUint8ArrayhookformdeepES8jsconcatMapgenericsreact-hook-formsymlinkkeyassertarraybufferassertionfunctionreadablepredictableURLtrimStartincludesassignajvremovetermhardlinksdependency managerdomtestES6flattentoolkitreact-testing-libraryairbnbArray.prototype.flatMapsyntaxerrores2017fastcloneselfserializeagentreacthooksexittypedweakmapwidthpackagesnativeclassnameprivate datasqsmappyyamlimportcurriedletsafeprogresserror-handlingeast-asian-widthmixinsfpefficientvaluesECMAScript 7checkio-tses-shim APIaccessormatchAllirqsharedarraybufferttyarray
3.4.75

11 months ago

3.4.74

11 months ago

3.4.73

11 months ago

3.4.72

11 months ago

3.4.71

11 months ago

3.4.70

11 months ago

3.3.70

11 months ago

3.3.69

11 months ago

3.3.68

11 months ago

3.3.67

11 months ago

3.3.66

11 months ago

3.3.65

11 months ago

3.3.64

11 months ago

3.3.63

11 months ago

3.3.62

11 months ago

3.3.61

11 months ago

2.3.61

11 months ago

2.3.60

11 months ago

2.3.59

12 months ago

2.3.58

12 months ago

2.3.57

12 months ago

2.3.56

12 months ago

2.3.55

12 months ago

2.3.54

12 months ago

2.3.53

12 months ago

2.3.52

12 months ago

2.2.52

12 months ago

2.2.51

12 months ago

2.2.50

12 months ago

2.2.49

12 months ago

2.2.48

12 months ago

2.2.47

12 months ago

2.2.46

12 months ago

2.2.45

12 months ago

2.2.44

12 months ago

2.2.43

12 months ago

2.2.42

12 months ago

2.2.41

12 months ago

2.2.40

1 year ago

2.2.39

1 year ago

2.2.38

1 year ago

2.2.37

1 year ago

2.2.36

1 year ago

2.2.35

1 year ago

2.2.34

1 year ago

2.2.33

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.1.31

1 year ago

2.1.30

1 year ago

2.1.29

1 year ago

2.1.28

1 year ago

2.1.27

1 year ago

2.1.26

1 year ago

2.1.25

1 year ago

2.1.24

1 year ago

2.1.23

1 year ago

2.1.22

1 year ago

2.1.21

1 year ago

2.0.21

1 year ago

2.0.20

1 year ago

2.0.19

1 year ago

2.0.18

1 year ago

2.0.17

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago