Sha256: 0334c6a8d2cdac1ae63e4ddaf9c931bc37cb4ffcdc31d13b21357f4be490a0d8

Contents?: true

Size: 1.8 KB

Versions: 27

Compression:

Stored size: 1.8 KB

Contents

var CC = require('../index.js').ConfigChain
var test = require('tap').test

var f1 = '/tmp/f1.ini'
var f2 = '/tmp/f2.json'

var ini = require('ini')

var f1data = {foo: {bar: 'baz'}, bloo: 'jaus'}
var f2data = {oof: {rab: 'zab'}, oolb: 'suaj'}

var fs = require('fs')

fs.writeFileSync(f1, ini.stringify(f1data), 'utf8')
fs.writeFileSync(f2, JSON.stringify(f2data), 'utf8')

test('test saving and loading ini files', function (t) {
  new CC()
    .add({grelb:'blerg'}, 'opt')
    .addFile(f1, 'ini', 'inifile')
    .addFile(f2, 'json', 'jsonfile')
    .on('load', function (cc) {

      t.same(cc.snapshot, { grelb: 'blerg',
                            bloo: 'jaus',
                            foo: { bar: 'baz' },
                            oof: { rab: 'zab' },
                            oolb: 'suaj' })

      t.same(cc.list, [ { grelb: 'blerg' },
                        { bloo: 'jaus', foo: { bar: 'baz' } },
                        { oof: { rab: 'zab' }, oolb: 'suaj' } ])

      cc.set('grelb', 'brelg', 'opt')
        .set('foo', 'zoo', 'inifile')
        .set('oof', 'ooz', 'jsonfile')
        .save('inifile')
        .save('jsonfile')
        .on('save', function () {
          t.equal(fs.readFileSync(f1, 'utf8'),
                  "bloo = jaus\nfoo = zoo\n")
          t.equal(fs.readFileSync(f2, 'utf8'),
                  "{\"oof\":\"ooz\",\"oolb\":\"suaj\"}")

          t.same(cc.snapshot, { grelb: 'brelg',
                                bloo: 'jaus',
                                foo: 'zoo',
                                oof: 'ooz',
                                oolb: 'suaj' })

          t.same(cc.list, [ { grelb: 'brelg' },
                            { bloo: 'jaus', foo: 'zoo' },
                            { oof: 'ooz', oolb: 'suaj' } ])

          t.pass('ok')
          t.end()
        })
    })
})

Version data entries

27 entries across 20 versions & 3 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.4.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.4.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
gulp_assets-1.0.0.pre.5 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/npmconf/node_modules/config-chain/test/save.js
gulp_assets-1.0.0.pre.4 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/npmconf/node_modules/config-chain/test/save.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.2.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.1.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.0.8 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.0.7 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
hooch-0.0.6 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.16 spec/dummy/public/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.16 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.15 spec/dummy/public/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.15 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.14 spec/dummy/public/node_modules/phantomjs/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.14 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/test/save.js
entangled-0.0.13 spec/dummy/public/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/test/save.js