Do not print error banner for shell proxy commands · npm/cli@4e58274 (original) (raw)

`@@ -43,6 +43,7 @@ const config = {

`

43

43

`const npm = {

`

44

44

`version: '1.0.0',

`

45

45

` config,

`

``

46

`+

shelloutCommands: ['exec', 'run-script'],

`

46

47

`}

`

47

48

``

48

49

`const npmlog = {

`

`@@ -525,3 +526,64 @@ t.test('use exitCode when emitting exit event', (t) => {

`

525

526

``

526

527

`process.emit('exit')

`

527

528

`})

`

``

529

+

``

530

`+

t.test('do no fancy handling for shellouts', t => {

`

``

531

`+

const { exit } = process

`

``

532

`+

const { command } = npm

`

``

533

`+

const { log } = npmlog

`

``

534

`+

const LOG_RECORD = []

`

``

535

`+

t.teardown(() => {

`

``

536

`+

npmlog.log = log

`

``

537

`+

process.exit = exit

`

``

538

`+

npm.command = command

`

``

539

`+

})

`

``

540

+

``

541

`+

npmlog.log = function (level, ...args) {

`

``

542

`+

log.call(this, level, ...args)

`

``

543

`+

LOG_RECORD.push(npmlog.record[npmlog.record.length - 1])

`

``

544

`+

}

`

``

545

+

``

546

`+

npm.command = 'exec'

`

``

547

+

``

548

`+

let EXPECT_EXIT = 0

`

``

549

`+

process.exit = code => {

`

``

550

`+

t.equal(code, EXPECT_EXIT, 'got expected exit code')

`

``

551

`+

EXPECT_EXIT = 0

`

``

552

`+

}

`

``

553

`+

t.beforeEach((cb) => {

`

``

554

`+

LOG_RECORD.length = 0

`

``

555

`+

cb()

`

``

556

`+

})

`

``

557

+

``

558

`+

const loudNoises = () => LOG_RECORD

`

``

559

`+

.filter(({ level }) => ['warn', 'error'].includes(level))

`

``

560

+

``

561

`+

t.test('shellout with a numeric error code', t => {

`

``

562

`+

EXPECT_EXIT = 5

`

``

563

`+

errorHandler(Object.assign(new Error(), { code: 5 }))

`

``

564

`+

t.equal(EXPECT_EXIT, 0, 'called process.exit')

`

``

565

`+

// should log no warnings or errors, verbose/silly is fine.

`

``

566

`+

t.strictSame(loudNoises(), [], 'no noisy warnings')

`

``

567

`+

t.end()

`

``

568

`+

})

`

``

569

+

``

570

`+

t.test('shellout without a numeric error code (something in npm)', t => {

`

``

571

`+

EXPECT_EXIT = 1

`

``

572

`+

errorHandler(Object.assign(new Error(), { code: 'banana stand' }))

`

``

573

`+

t.equal(EXPECT_EXIT, 0, 'called process.exit')

`

``

574

`+

// should log some warnings and errors, because something weird happened

`

``

575

`+

t.strictNotSame(loudNoises(), [], 'bring the noise')

`

``

576

`+

t.end()

`

``

577

`+

})

`

``

578

+

``

579

`+

t.test('shellout with code=0 (extra weird?)', t => {

`

``

580

`+

EXPECT_EXIT = 1

`

``

581

`+

errorHandler(Object.assign(new Error(), { code: 0 }))

`

``

582

`+

t.equal(EXPECT_EXIT, 0, 'called process.exit')

`

``

583

`+

// should log some warnings and errors, because something weird happened

`

``

584

`+

t.strictNotSame(loudNoises(), [], 'bring the noise')

`

``

585

`+

t.end()

`

``

586

`+

})

`

``

587

+

``

588

`+

t.end()

`

``

589

`+

})

`