]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/init-package-json/test/scope-in-config-existing-name.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / init-package-json / test / scope-in-config-existing-name.js
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/init-package-json/test/scope-in-config-existing-name.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/init-package-json/test/scope-in-config-existing-name.js
new file mode 100644 (file)
index 0000000..39dc90f
--- /dev/null
@@ -0,0 +1,30 @@
+var fs = require('fs')
+var path = require('path')
+
+var rimraf = require('rimraf')
+var tap = require('tap')
+
+var init = require('../')
+
+var json = {
+  name: '@already/scoped',
+  version: '1.0.0'
+}
+
+tap.test('with existing package.json', function (t) {
+  fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify(json, null, 2))
+  console.log(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'))
+  console.error('wrote json', json)
+  init(__dirname, __dirname, { yes: 'yes', scope: '@still' }, function (er, data) {
+    if (er) throw er
+
+    console.log('')
+    t.equal(data.name, '@still/scoped', 'new scope is added, basic name is kept')
+    t.end()
+  })
+})
+
+tap.test('teardown', function (t) {
+  rimraf.sync(path.join(__dirname, 'package.json'))
+  t.end()
+})