Comments (13)
I believe this one can be closed now. It might not be too bad idea to add the above comment by @SBoudrias to README.md
as it's useful information when composing generators with this one.
from generator-license.
@razzeee you can get it from the generated package.json
license
field.
this.fs.readJSON(this.destinationPath('package.json')).license;
from generator-license.
Unfortunatly I need it before I write the files, as I need to write it to one of the files I'm writing it too. Not sure how to do it. My code is here: https://github.com/Razzeee/generator-kodi/blob/master/generators/app/index.js
from generator-license.
@razzeee you use this.props.license
after the prompt has been answered it will be populated with value
from licenses
(so it will be MIT
or Apache-2.0
or GPL-3.0
etc.).
You can see how filename is generated by appending .txt
to what you chose on https://github.com/jozefizso/generator-license/blob/master/app/index.js#L100
Hope this helps.
from generator-license.
@ek9
the variable doesn't seem to be filed, probably due to the scope being a different one
from generator-license.
Yeoman generators run in isolation. They don't return values.
The only way to get the selected license is from reading the value from the package.json.
You should read about the run loop here http://yeoman.io/authoring/running-context.html and order your tasks in a way where you'll be able to grab the license value from package.json to add it elsewhere.
from generator-license.
@SBoudrias
so your saying that I need a package.json to solve this? I'm creating python code, so I'm not creating a package.json
from generator-license.
@razzeee so you want the license to include in setup.py
?
Maybe we could add support for adding the license inside setup.py directly in this generator.
from generator-license.
nope, I want to add it to a addon.xml as it's a generator for a kodi addon :/
from generator-license.
Well adding things to addon.xml
isn't part of this package's scope. What I believe you should be doing:
- Show the prompt in your generator, where user can pick license
- Use this generator as a sub generator and pass the license as an option, so this generator uses it.
However, this is likely to require some updates to this package too, as even when provided with some options, it still asks you to confirm things or would provide the questions multiple times. To avoid this, there needs to be some updating on when certain prompts are shown.
I plan to play around with some generators later this week, and wanted to use this one as sub-generator. Perhaps I can answer in more detail later or provide a PR which would make it possible to implement it with this.
from generator-license.
Well could I just have my own license list and just add a matching license to options when running composeWith? If the generator does the rest of work needed, I'm fine.
Will try and update later.
from generator-license.
You can find an example on how generator-node
uses this module when asking which license to pick
https://github.com/yeoman/generator-node/blob/master/generators/app/index.js#L277
This also happens if you run yo generator
(need generator-generator
installed for that) as it calls generator-node::app
which in turn calls generator-license::app
)
The PR that is needed for you need is ability to provide "license" as an option (same way you can do with name etc.), so the license can be skipped. That way, you can have prompt in your own generator and only supply a license value to this generator. Otherwise, it will ask you for license 2nd time.
Also useful documentation on composability of Yeoman Generators: http://yeoman.io/authoring/composability.html
from generator-license.
require('generator-license').licenses
is the list of license this generator supports. So you can use that.
from generator-license.
Related Issues (20)
- Issue migrating to TypeScript HOT 10
- Move to GitHub Actions
- Move to Node.js v14 LTS HOT 1
- Audit packages HOT 1
- Configure coveralls
- Consider removing dev dependencies before publishing a package. HOT 7
- Additional LICENSEs HOT 3
- Year rendered as `NaN` when entering a range (e.g. 2013-2015)
- ESLint for the project HOT 2
- Coveralls.io integration for test coverage tracking HOT 3
- Tests always fail locally
- Configuration for users HOT 1
- Add Support For No Email & Website HOT 3
- Remove redundant git-config dep
- Options not honored when using composeWith() HOT 1
- Deleting license field when value is UNLICENSED seems to be incorrect HOT 1
- Vulnerable dependency - hapijs/hoek package HOT 1
- Update build configuration
- Failed build - Client request error: getaddrinfo ENOTFOUND api.nodesecurity.io HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator-license.