]> gerrit.simantics Code Review - simantics/district.git/blob - scope-in-config-existing-name.js
39dc90f4292456561cb4f68ec22f3e8112dcda8c
[simantics/district.git] / scope-in-config-existing-name.js
1 var fs = require('fs')
2 var path = require('path')
3
4 var rimraf = require('rimraf')
5 var tap = require('tap')
6
7 var init = require('../')
8
9 var json = {
10   name: '@already/scoped',
11   version: '1.0.0'
12 }
13
14 tap.test('with existing package.json', function (t) {
15   fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify(json, null, 2))
16   console.log(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'))
17   console.error('wrote json', json)
18   init(__dirname, __dirname, { yes: 'yes', scope: '@still' }, function (er, data) {
19     if (er) throw er
20
21     console.log('')
22     t.equal(data.name, '@still/scoped', 'new scope is added, basic name is kept')
23     t.end()
24   })
25 })
26
27 tap.test('teardown', function (t) {
28   rimraf.sync(path.join(__dirname, 'package.json'))
29   t.end()
30 })