1.0.2 • Published 8 years ago
@neo9/n9-node-sonar-generate v1.0.2
n9-node-sonar-generate
Generate a sonar-project.properties file based on the project package.json.
Installation
npm install --save-dev @neo9/n9-node-sonar-generateUsage
In your package.json add the end of your test script, add n9-sonar-generate command:
{
"scripts": {
"test": "... && n9-sonar-generate"
}
}Default
For this example, we asume that pkg is the representation of package.json.
n9-sonar-generate will create a sonar-project.properties file with these properties:
sonar.projectKey = pkg.name || pkg.sonar.projectKeysonar.projectName = pkg.description || pkg.sonar.projectNamesonar.projectVersion = pkg.version || pkg.sonar.projectVersionsonar.sources = pkg.sonar.sources || ./srcsonar.sourceEncoding = pkg.sonar.sourceEncoding || UTF-8sonar.tests = pkg.sonar.tests || ./test
Configuration
Every key added to the sonar property in the package.json will be added to sonar-project.properties with the sonar. prefix.
Example:
package.json
{
"sonar": {
"host.url": "http://localhost:9000"
}
}Will add to sonar-project.properties:
sonar.host.url=http://localhost:9000TypeScript Project
To use with a TypeScript project, please add the following to your package.json:
Example:
{
"sonar": {
"coverage.exclusions": "src/*.d.ts",
"ts.coverage.lcovReportPath": "./coverage/lcov.info",
"ts.tslint.path": "./node_modules/.bin/tslint",
"ts.tslint.configPath": "./tslint.json"
}
}Gitignore
Don't forget to add sonar-project.properties in your .gitignore