"Fossies" - the Fresh Open Source Software Archive

Member "node-v12.18.4-win-x86/node_modules/npm/scripts/maketest" (14 Feb 2020, 1926 Bytes) of package /windows/www/node-v12.18.4-win-x86.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env node
    2 'use strict'
    3 const loadFromDir = require('tacks/load-from-dir.js')
    4 
    5 process.exit(main(process.argv.slice(2)))
    6 
    7 function main (argv) {
    8   if (argv.length !== 1) {
    9     console.error('Usage: maketest <fixturedir>')
   10     return 1
   11   }
   12   const fixturedir = process.argv[2]
   13 
   14   console.log(generateFromDir(fixturedir))
   15   return 0
   16 }
   17 
   18 function indent (ind, str) {
   19   return str.replace(/\n/g, '\n' + ind)
   20 }
   21 
   22 function generateFromDir (dir) {
   23   const tacks = loadFromDir(dir)
   24   return `'use strict'
   25 const path = require('path')
   26 const test = require('tap').test
   27 const Tacks = require('tacks')
   28 const File = Tacks.File
   29 const Symlink = Tacks.Symlink
   30 const Dir = Tacks.Dir
   31 const common = require('../common-tap.js')
   32 
   33 const basedir = path.join(__dirname, path.basename(__filename, '.js'))
   34 const testdir = path.join(basedir, 'testdir')
   35 const cachedir = path.join(basedir, 'cache')
   36 const globaldir = path.join(basedir, 'global')
   37 const tmpdir = path.join(basedir, 'tmp')
   38 
   39 const conf = {
   40   cwd: testdir,
   41   env: common.newEnv().extend({
   42     npm_config_cache: cachedir,
   43     npm_config_tmp: tmpdir,
   44     npm_config_prefix: globaldir,
   45     npm_config_registry: common.registry,
   46     npm_config_loglevel: 'warn'
   47   })
   48 }
   49 
   50 const fixture = new Tacks(Dir({
   51   cache: Dir(),
   52   global: Dir(),
   53   tmp: Dir(),
   54   testdir: ${indent('  ', tacks.fixture.toSource())}
   55 }))
   56 
   57 function setup () {
   58   cleanup()
   59   fixture.create(basedir)
   60 }
   61 
   62 function cleanup () {
   63   fixture.remove(basedir)
   64 }
   65 
   66 test('setup', t => {
   67   setup()
   68   return common.fakeRegistry.listen()
   69 })
   70 
   71 test('example', t => {
   72   return common.npm(['install'], conf).then(([code, stdout, stderr]) => {
   73     t.is(code, 0, 'command ran ok')
   74     t.comment(stdout.trim())
   75     t.comment(stderr.trim())
   76     // your assertions here
   77   })
   78 })
   79 
   80 test('cleanup', t => {
   81   common.fakeRegistry.close()
   82   cleanup()
   83   t.done()
   84 })\n`
   85 }