npm / promzard Goto Github PK
View Code? Open in Web Editor NEWA prompting json thingie
License: ISC License
A prompting json thingie
License: ISC License
n/a
It seems that here is a mistype:
d = a.default || d
t = a.tranform || t
}
tranform
-> transform
I'm not seeing a way to prompt conditionally or conditionally create an object. As a concrete example of both, consider a fancier way of prompting for the repository information from npm init
. First, we prompt for the repo type:
repository type:
Now, if the user enters a value, we would prompt for the repository itself:
git repository:
-or-
svn repository:
(Yes, I know having different prompts in this case is silly; it's just a convenient example.)
If the user entered no value for repository type, though, we would not prompt for the repository URL at all.
If the user then enters a URL, the result would be:
{ type: "git", url: "my git url" }
but if the user did not enter a URL (or did not enter a type), we would leave the result undefined (i.e. no object at all), so that none of the repository structure would show up in package.json.
Is there a way to do this?
n/a
n/a
Feature bloat request: I want to color the prompt.
n/a
Regarding the class promzard.PromZard
the docs say:
Emits either a
data
event with the data, or aerror
event if it blows up. Iferror
is emitted, thendata
never will be.
The following code throws an error in the input file. The result is that both error
and data
events are emitted.
const fs = require('fs')
const path = require('path')
const { inspect } = require('util')
const { PromZard } = require('promzard')
const inputFile = path.resolve(__dirname, 'input.js')
fs.writeFileSync(inputFile, `throw new Error('Break stuff')`)
const pz = new PromZard(inputFile, {})
pz.on('error', err => console.log('error: ' + err))
pz.on('data', data => console.log('data: ' + inspect(data)))
Output:
error: Error: Break stuff
data: {}
An example for effect in the wild: This bug causes init-package-json
to continue wanting to write a file even after an error occurred during processing of the input file. Sample output using the input file from above with init-package-json
:
Break stuff
About to write to /tmp/tmp.1uWPpEnFlC/package.json:
{
"name": "",
"version": ""
}
Is this OK? (yes) n
Aborted.
neat module @isaacs I'm wondering if there's a way to reprompt when a field fails validation? For instance example/npm-init/init-input.js reads version, but there's nothing preventing me from typing 'heh' at the prompt and having that accepted. I'd want to enforce semver for this field, and ditto for other field types. I looked at isaacs/npm/blob/master/lib/adduser.js to see how this was achieved, and notice it doesnt rely on promzard (uses your read package at a lower level.) Is this an intentional design decision, or what?
The tap version in debian unstable is 10.7.2, and the tests are failing against the new version.
n/a
if we use virtual files we will want to be able to load from a buffer, being able to pass in a buffer to load rather than a filename would be nice.
discovered during: npm/npm#7551
Please add a license file to clarify what license this is distributed under.
I'd like to use node/npm for a project at work, but npm depends on this package and I'm not allowed to use software that doesn't have a clear license.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.