From my last question - npm version "scripts have access to the new version in package.json"
How do you output JS / JSON from an NPM script. After an npm version
I am writing that out to a JS / JSON file to be picked up in Angular with an import like what I've written at the bottom of this post
I tried these variations of the following:
"version": "version=$(git tag | head -1); echo "{version:$version}" > client/src/app/config-from-npm.json",
- single quote (') instead of double (") in all cases
echo '{version:...
- error Unexpected token { in JSON
echo '%7Bversion:...
- outputs '%7Bversion ...'
echo '%7Bversion:...
- outputs '{version ...'
Angular import of version number
What I'm trying to achieve and how it will be used:
export var config = {
version: v1.0.0
}
----
import { config } from './config';
If I don't work out this '{' in JS / JSON problem I will just write the version number to file and read in. Nowhere near as neat!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…