VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /usr/local/lib/node_modules/browserify/node_modules/module-deps/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/node_modules/browserify/node_modules/module-deps/test/ignore_missing.js
var parser = require('../');
var test = require('tap').test;
var fs = require('fs');
var path = require('path');

var files = {
    main: path.join(__dirname, '/ignore_missing/main.js'),
    other: path.join(__dirname, '/ignore_missing/other.js')
};

var sources = Object.keys(files).reduce(function (acc, file) {
    acc[file] = fs.readFileSync(files[file], 'utf8');
    return acc;
}, {});

test('ignoreMissing', function (t) {
    t.plan(1);
    var p = parser({ignoreMissing: true});
    p.end({file: files.main, entry: true});
    
    var rows = [];
    p.on('data', function (row) { rows.push(row) });
    p.on('end', function () {
        t.same(rows.sort(cmp), [
            {
                id: files.main,
                file: files.main,
                source: sources.main,
                entry: true,
                deps: { './other': files.other }
            },
            {
                id: files.other,
                file: files.other,
                source: sources.other,
                deps: { 'missingModule': undefined }
            }
        ].sort(cmp));
    });
});

test('ignoreMissing off', function (t) {
    t.plan(1);
    var p = parser();
    p.end({file: files.main, entry: true});
    
    var rows = [];
    p.on('data', function (row) { rows.push(row) });
    p.on('error', function (err) {
        t.match(
            String(err),
            /Cannot find module 'missingModule'/
        );
    });
    p.on('end', function () {
        t.fail('should have errored');
    });
});

function cmp (a, b) { return a.id < b.id ? -1 : 1 }

VaKeR 2022