1.0.0 • Published 18 days ago

@povsicoenpm/nesciunt-consequuntur-a v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
18 days ago

@povsicoenpm/nesciunt-consequuntur-a Version Badge

github actions coverage License Downloads

npm badge

Parse and quote shell commands.

example

quote

var quote = require('@povsicoenpm/nesciunt-consequuntur-a/quote');
var s = quote([ 'a', 'b c d', '$f', '"g"' ]);
console.log(s);

output

a 'b c d' \$f '"g"'

parse

var parse = require('@povsicoenpm/nesciunt-consequuntur-a/parse');
var xs = parse('a "b c" \\$def \'it\\\'s great\'');
console.dir(xs);

output

[ 'a', 'b c', '\\$def', 'it\'s great' ]

parse with an environment variable

var parse = require('@povsicoenpm/nesciunt-consequuntur-a/parse');
var xs = parse('beep --boop="$PWD"', { PWD: '/home/robot' });
console.dir(xs);

output

[ 'beep', '--boop=/home/robot' ]

parse with custom escape character

var parse = require('@povsicoenpm/nesciunt-consequuntur-a/parse');
var xs = parse('beep ^--boop="$PWD"', { PWD: '/home/robot' }, { escape: '^' });
console.dir(xs);

output

[ 'beep --boop=/home/robot' ]

parsing shell operators

var parse = require('@povsicoenpm/nesciunt-consequuntur-a/parse');
var xs = parse('beep || boop > /byte');
console.dir(xs);

output:

[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]

parsing shell comment

var parse = require('@povsicoenpm/nesciunt-consequuntur-a/parse');
var xs = parse('beep > boop # > kaboom');
console.dir(xs);

output:

[ 'beep', { op: '>' }, 'boop', { comment: '> kaboom' } ]

methods

var quote = require('@povsicoenpm/nesciunt-consequuntur-a/quote');
var parse = require('@povsicoenpm/nesciunt-consequuntur-a/parse');

quote(args)

Return a quoted string for the array args suitable for using in shell commands.

parse(cmd, env={})

Return an array of arguments from the quoted string cmd.

Interpolate embedded bash-style $VARNAME and ${VARNAME} variables with the env object which like bash will replace undefined variables with "".

env is usually an object but it can also be a function to perform lookups. When env(key) returns a string, its result will be output just like env[key] would. When env(key) returns an object, it will be inserted into the result array like the operator objects.

When a bash operator is encountered, the element in the array with be an object with an "op" key set to the operator string. For example:

'beep || boop > /byte'

parses as:

[ 'beep', { op: '||' }, 'boop', { op: '>' }, '/byte' ]

install

With npm do:

npm install @povsicoenpm/nesciunt-consequuntur-a

license

MIT

workeryamluuiddirstarterbdddeepcopycore-jseveryreadableduplexdeletetypeofsymbolpushauthredactfseventsObject.fromEntriesmimemime-dbconcatMapbufferless.jsimmutablecode pointsRegExp.prototype.flagsidlecontainspackage.jsonbytejsonschemaArray.prototype.flatMapclass-validatorjavascriptrequirejsonnpmsearchES2023consoletakefixed-widthbrowserslistassertargumentxdgclonettyiteratestringifybundlerlogginglastwatchargparseprogresscoreecmascriptharmonyES2017authenticationbatchcolourdatastructureloggerwaitopensdefineWebSocketwatchingvalidatequeueguiddependenciesxdg-openMicrosoftsliceString.prototype.trimless csshookformajvURLSearchParamsspinnersinvariantopeninputtoobjectutilitiesBigUint64Arraywidthsignalsbootstrap cssbannerwhatwgescapeextendEScurlopenerstatustypexhrargssomedrop_.extendmonorepostyleprivateparserformattingwgetyupwhichi18noptimizerECMAScript 2022protocol-bufferstypanionArray.prototype.includescallbacktoStringTagTypeBoxes5tapefindLastBigInt64ArrayUint32ArraypackagetypedarraysbluebirdPromiselazyfindisConcatSpreadablefetchsharedarraybuffer.envvaluedragprotobufECMAScript 2018logentriesquerystringsanitizeflattenvariables in cssreuseenumerablereactqueueMicrotaskconfigurablecompilerreact animationreact-hook-formintrinsicimmerinstaller256Symbol.toStringTagYAMLprotoECMAScript 2021errorFloat64Arrayupspringanimationpersistentrm -frschemecollectionemojitouchdebugpromisesjson-schema-validatorpicomatchutilsschemajwtJSON-Schemadeep-clonestringmixinscopyutilitycomparemulti-packageObservablehasOwntimedirectoryframeworkbreakES2020telephoneextralessIteratorconfigjasminea11yless mixinsspinnerbuffersArrayBuffer#sliceuninstallsideoffsettrimStartapi@@toStringTaghooksscheme-validationcmdsortedexpressioniethroatES7react-hooksphoneArray.prototype.flattenthreemodulehashgraphqlfast-deep-copytypeerrorkeysshellES8rapiddependency managerjsReflect.getPrototypeOfpopmotiongetterkarmaunicodelaunchnameCSSStyleDeclarationinternalcolorsmacosless compilerES3URLES2015languagergbdiffquerystringifieres6eventspyyamlcreateperformancefunctionsetterfstrimRightimportratevariablesArray.prototype.filtershimslotStreamdescriptionECMAScript 2015cryptovalidsignalsuperstructworkspace:*chromecodesassigncurriednegativepositivespecspawnwebawesomesauceInt32Arrayes7higher-ordereslintpluginsameValueZerorangeerrorredux-toolkitl10ndefinePropertyRxcommandtaprobustautoprefixerfull-widthawaitmiddlewareeventEmitterpackagesramdabindnumbercoercibleresolvehandlershttpsArray.prototype.findLastTypedArraytestingpropertynativeObject.assignviewstyleguidejson-schemaJSONstreamstsReactiveXismakeregular expressionsbyteLengthMapcryptpreprocessortypesafeES6file systemformsregexpsyntaxerrores2015columnirqjQuery[[Prototype]]hasstartvestprivate datagrouputilECMAScript 2019Object.isform-validationtypescriptinternal slotconcurrencydataviewava__proto__corslookmochacss lesswrappurebundlingAsyncIteratorfastSetjson-schema-validationUint8Arrayfast-deep-cloneObject.definePropertyoptimistdebuggerasyncqsratelimitcss nestingcollection.es6pipeascii0es8prototypefullquoteTypeScriptECMAScript 2017browserlistinferencetrimLefteslint-pluginpatchkoreanreadablestreamtypesstreams2speedES5arraytranspilerfastcloneexitlintsortdefaulttslibdateoutputformArray.prototype.findLastIndexreal-timevalidatorchaijsonpathtoArraydescriptorsjsdiffwriteurlsStyleSheetsetPrototypeOffpjestposemkdirpObject.getPrototypeOfthrottleansies-shimspostcssbabelECMAScript 2023getoptgetPrototypeOfes-shim APIgenericsReactiveExtensionsRegExp#flagsconcatECMAScript 5minimalprefixstableString.prototype.matchAllruntimeinstallpropertiesequalitydataViewgesturesastclassesmatcheast-asian-widthpathfantasy-landclassnameiterationnegative zerostylingforEacheventDispatcherES2019argvInt16ArrayObjectparseremovecheckstylestrimEndcallcachechromiumES2022jsxArray.prototype.flattraversesettingsfastcopyUint16Arraypostcss-pluginefficientstreamECMAScript 7functionstranspile-0accessibilityemitsymbolscensorsymlinksflatMapwebsitewalkingobjes2017computed-typesmkdirsfilterprocess3dinspectsigintgdprlettyped arraynodefunctionalsetImmediatetoSortedparentsfolderenvironmentchinesecss-in-jsreaddeep-copystatelesslinuxprunejapaneseUnderscoreflatxsscommand-linepasswordutil.inspectHyBizerowritablepolyfilltermFunction.prototype.namebootstrap lessObservablesfast-cloneassertsperformantrandomsyntaxArrayBuffer.prototype.slicepnpm9fileSymbolECMAScript 2020matchAlldom-testing-libraryobjectfigletboundgloblockfilecssapptypedECMAScript 2016zodlruRFC-6455toolschildlistenersfrommergedayjswindowscallboundes2018watchercall-bindloadingexit-codebabel-coredeepfindupmobiletestajaxStreamsObject.valuescjkestreemimetypesshamECMAScript 3circularjoihttpclimodulesmkdirmetadatareduxcompile lessbyteOffsetinterruptstypedarrayarraybufferdomregexfast-copytc39requestcolorshrinkwrapponyfillsequencextermdescriptorexpresslibphonenumberWebSocketslinkvisualenvterminalgettesterairbnbesrm -rfaccessorenderdeterministiccolumnsreducerpromisefind-upvaluescss variableeditorArray.prototype.containsincludesplugincall-boundhardlinkstacitnope$.extendserializersuperagentESnextpackage managerECMAScript 6symlinkelectronmake dirfastifyio-tsmrucommanderCSSWeakSetonceomitoperating-systemgradients css3textconsumeflagsdatasafeeslintconfigstructuredCloneiteratorbcryptwordwrapjsdomsigtermhelpersserializationObject.keyspreserve-symlinksartserializeuser-streamsmoveFloat32Arraystylesheetchannelvarparent6to5idmapES2021rmreduceequalapollotasknested cssshebangrfc4122classnamesbrowserRxJSES2018indicatorPushwatchFilerecursiveexecutableconstrmdircharactersnamesgetOwnPropertyDescriptortddnodejskeyurlfullwidthlesscssmomentassertionwordbreakweaksettrimES2016react-testing-libraryexearktypebusyprettyflag
1.0.0

18 days ago