Skip to content

Getting 'TypeError: danger.git.JSONDiffForFile is not a function' #367

@svenmuennich

Description

@svenmuennich

When running a dangerfile containing a call to danger.git.JSONDiffForFile() on peril the following error is thrown:

error: UnhandledRejection Error:  TypeError: danger.git.JSONDiffForFile is not a function
	at _callee$ (/app/danger-0.9n2i29890gp.js:62:54)
	at Object.apply (/app/node_modules/vm2/lib/contextify.js:87:36)
	at tryCatch (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
	at Generator.invoke [as _invoke] (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:303:22)
	at tryCatch (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
	at Generator.prototype.(anonymous function) [as next] (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21)
	at invoke (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:155:20)
	at /app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:202:11
	at new Promise (<anonymous>)
	at callInvokeWithMethodAndArg (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:201:16)
/app/out/peril.js:25
throw reason;
^
TypeError: danger.git.JSONDiffForFile is not a function
	at _callee$ (/app/danger-0.9n2i29890gp.js:62:54)
	at Object.apply (/app/node_modules/vm2/lib/contextify.js:87:36)
	at tryCatch (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
	at Generator.invoke [as _invoke] (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:303:22)
	at Generator.prototype.(anonymous function) [as next] (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21)
	at tryCatch (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
	at invoke (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:155:20)
	at /app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:202:11
	at new Promise (<anonymous>)
	at callInvokeWithMethodAndArg (/app/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:201:16)

Here's an example dangerfile that should trigger the error.

import { danger } from 'danger';

(async function () {
    const modifiedComposerFile = danger.git.modified_files.find(file => file === 'composer.json');
    if (modifiedComposerFile) {
        const composerDiff = await danger.git.JSONDiffForFile(modifiedComposerFile);
    }
})();

Running the same dangerfile locally using the danger pr command works without error. We use the current latest commit of master (9b835cb). My local danger version is 3.8.8.

Is there any reason why JSONDiffForFile() would not be available in the object danger.git?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions