How to use the snyk.test function in snyk

To help you get started, we’ve selected a few snyk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github derekdorr / snyxy / index.js View on Github external
new Promise(function(resolve) {
                        let toTest = `${path}@${value}`;
                        let cachedState = packageCache[toTest];

                        if (cachedState !== undefined) {
                            if (cachedState === true) {
                                console.log('good:', toTest, '(from cache)');
                            } else {
                                delete versions[value];
                                console.log('bad:', toTest, '(from cache)');
                            }
                            resolve();
                        } else {
                            Snyk.test(toTest).then(function (data) {
                                if (data.ok !== true) {
                                    console.log('bad:', toTest);
                                    packageCache[toTest] = false;
                                    delete versions[value];
                                } else {
                                    packageCache[toTest] = true;
                                    console.log('good:', toTest);
                                }
                                resolve();
                                cacheChanged = true;
                            }, function (data) {
                                let sanitized = data || {};

                                if (sanitized.ok !== true) {
                                    console.log('bad:', toTest);
                                    packageCache[toTest] = false;

snyk

snyk library and cli utility

Apache-2.0
Latest version published 11 days ago

Package Health Score

76 / 100
Full package analysis