Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help needed: "ReferenceError: sonar is not defined" error #17

Closed
greenlaw110 opened this issue Jun 7, 2016 · 2 comments
Closed

Help needed: "ReferenceError: sonar is not defined" error #17

greenlaw110 opened this issue Jun 7, 2016 · 2 comments

Comments

@greenlaw110
Copy link

I put exactly the same code for sonar task in my gulpfile.js file:

gulp.task('sonar', function () {
    var options = {
        sonar: {
            host: {
                url: 'http://localhost:9000'
            },
            projectKey: 'conn-ui',
            projectName: 'Conn App UI',
            //projectVersion: '1.0.0',
            // comma-delimited string of source directories 
            sources: 'app/js,app/lib',
            language: 'js',
            sourceEncoding: 'UTF-8',
            javascript: {
                lcov: {
                    reportPath: 'test/sonar_report/lcov.info'
                }
            },
            exec: {
                // All these properties will be send to the child_process.exec method (see: https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback ) 
                // Increase the amount of data allowed on stdout or stderr (if this value is exceeded then the child process is killed, and the gulp-sonar will fail). 
                maxBuffer : 1024*1024
            }
        }
    };

    // gulp source doesn't matter, all files are referenced in options object above 
    return gulp.src('thisFileDoesNotExist.js', { read: false })
        .pipe(sonar(options))
        .on('error', util.log);
});

However I always get the following error messages when I invoke gulp sonar command:

using args { _: [ 'sonar' ], env: 'local-java', e: 'local-java' }
[15:36:54] Using gulpfile ~/p/conn/ui/app/gulpfile.js
[15:36:54] Starting 'sonar'...
[15:36:54] 'sonar' errored after 7.8 ms
[15:36:54] ReferenceError: sonar is not defined
    at Gulp.<anonymous> (/home/luog/p/conn/ui/app/gulpfile.js:495:15)
    at module.exports (/home/luog/p/conn/ui/app/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask (/home/luog/p/conn/ui/app/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep (/home/luog/p/conn/ui/app/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start (/home/luog/p/conn/ui/app/node_modules/orchestrator/index.js:134:8)
    at /usr/lib/node_modules/gulp/bin/gulp.js:129:20
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
    at Function.Module.runMain (module.js:449:11)
    at startup (node.js:148:18)
    at node.js:405:3

Do you know where I am wrong?

@greenlaw110 greenlaw110 changed the title Doesn't work for me Help needed: "ReferenceError: sonar is not defined" error Jun 7, 2016
@ashleyconnor
Copy link
Contributor

Do you have var sonar = require('sonar'); at the top of your gulpfile.js?

@greenlaw110
Copy link
Author

yep I noticed that and problem resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants