How to use the cson.load function in cson

To help you get started, we’ve selected a few cson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liuderchi / atom-i18n / spec / validation.js View on Github external
it('fetches descriptive part of config-schema.js then compares keys of settings.cson with it', async () => {
        const neverShownDesciptionInSettingsPanelItems = [
          'core.customFileTypes',
          'core.disabledPackages',
          'core.themes',
          'editor.invisibles',   // NOTE shows only editor.invisibles.*
        ]    // NOTE Manually updated exceptional list from https://github.com/atom/settings-view/blob/master/lib/settings-panel.js#L339-L350

        const templateSettingsControls = CSON.load(path.join(__dirname, '../def/template', 'settings.cson'))
          .Settings.settings.controls.map(({ _id }) => _id)

        const axios = require('axios')
        const configURL = `https://raw.githubusercontent.com/atom/atom/${ATOM_VERSION}/src/config-schema.js`
        console.info(`fetching ${configURL}...`)

        const flattenSrcConfigKeys = await axios.get(configURL).then(({ data }) => {
          const srcConfig = eval(data)
          const keysWithoutDescriptionToKeep = [
            'core.autoHideMenuBar', // platform specific
          ]
          return Object.keys(flattenObj(srcConfig))
            .filter(key => key.search(/enum/g) === -1)
            .filter(key => key.search(/description$/g) !== -1)
            .concat(keysWithoutDescriptionToKeep)
            .map(key => key.replace(/\.properties/g, '').replace(/\.description/g, ''))
github simonknittel / discord-bot-api / src / modules / config.js View on Github external
function reload(callback) {
    config = CSON.load('./config.cson'); // Load the config from the config.cson
    events.emit('config reloaded');
    automaticReload(); // eslint-disable-line no-use-before-define
    if (callback) callback();
}
reload();
github viko16 / boost2fs / index.js View on Github external
async readNote (fileName) {
    const filePath = path.resolve(this.inputPath, 'notes', fileName)
    // Parses a CSON file into an Object
    const parsedObj = await cson.load(filePath)
    // Skip the deleted note
    if (parsedObj.isTrashed === true) return

    switch (parsedObj.type) {
      case NOTE_TYPE.MARKDOWN_NOTE:
        await this.parseMarkdownNote(parsedObj)
        break
      case NOTE_TYPE.SNIPPET_NOTE:
        await this.parseSnippetNote(parsedObj)
        break
      default:
        console.info('unhandle type: ', parsedObj.type)
        break
    }
  }
github liuderchi / atom-i18n / lib / main.js View on Github external
constructor() {
    this.pref = { done: false }
    this.delay = this.delay.bind(this)
    this.customMenuI18n = this.customMenuI18n.bind(this)
    const LOCALE = atom.config.get('atom-i18n.locale')
    // BUG when running spec, LOCALE is not initialized
    if (!atom.config.get('atom-i18n.customMenuI18nPath')) {
      atom.config.set('atom-i18n.customMenuI18nPath', path.join(__dirname, '../def', 'custom_menu.cson'))
    }
    this.defM = CSON.load(path.join(__dirname, '../def', LOCALE, `menu_${process.platform}.cson`))
    this.defC = CSON.load(path.join(__dirname, '../def', LOCALE, 'context.cson'))
    this.defS = CSON.load(path.join(__dirname, '../def', LOCALE, 'settings.cson'))
    this.defA = CSON.load(path.join(__dirname, '../def', LOCALE, 'about.cson'))
    this.defW = CSON.load(path.join(__dirname, '../def', LOCALE, 'welcome.cson'))
  }
github liuderchi / atom-i18n / lib / main.js View on Github external
constructor() {
    this.pref = { done: false }
    this.delay = this.delay.bind(this)
    this.customMenuI18n = this.customMenuI18n.bind(this)
    const LOCALE = atom.config.get('atom-i18n.locale')
    // BUG when running spec, LOCALE is not initialized
    if (!atom.config.get('atom-i18n.customMenuI18nPath')) {
      atom.config.set('atom-i18n.customMenuI18nPath', path.join(__dirname, '../def', 'custom_menu.cson'))
    }
    this.defM = CSON.load(path.join(__dirname, '../def', LOCALE, `menu_${process.platform}.cson`))
    this.defC = CSON.load(path.join(__dirname, '../def', LOCALE, 'context.cson'))
    this.defS = CSON.load(path.join(__dirname, '../def', LOCALE, 'settings.cson'))
    this.defA = CSON.load(path.join(__dirname, '../def', LOCALE, 'about.cson'))
    this.defW = CSON.load(path.join(__dirname, '../def', LOCALE, 'welcome.cson'))
  }
github liuderchi / atom-i18n / lib / main.js View on Github external
constructor() {
    this.pref = { done: false }
    this.delay = this.delay.bind(this)
    this.customMenuI18n = this.customMenuI18n.bind(this)
    const LOCALE = atom.config.get('atom-i18n.locale')
    // BUG when running spec, LOCALE is not initialized
    if (!atom.config.get('atom-i18n.customMenuI18nPath')) {
      atom.config.set('atom-i18n.customMenuI18nPath', path.join(__dirname, '../def', 'custom_menu.cson'))
    }
    this.defM = CSON.load(path.join(__dirname, '../def', LOCALE, `menu_${process.platform}.cson`))
    this.defC = CSON.load(path.join(__dirname, '../def', LOCALE, 'context.cson'))
    this.defS = CSON.load(path.join(__dirname, '../def', LOCALE, 'settings.cson'))
    this.defA = CSON.load(path.join(__dirname, '../def', LOCALE, 'about.cson'))
    this.defW = CSON.load(path.join(__dirname, '../def', LOCALE, 'welcome.cson'))
  }
github liuderchi / atom-i18n / lib / main.js View on Github external
constructor() {
    this.pref = { done: false }
    this.delay = this.delay.bind(this)
    this.customMenuI18n = this.customMenuI18n.bind(this)
    const LOCALE = atom.config.get('atom-i18n.locale')
    // BUG when running spec, LOCALE is not initialized
    if (!atom.config.get('atom-i18n.customMenuI18nPath')) {
      atom.config.set('atom-i18n.customMenuI18nPath', path.join(__dirname, '../def', 'custom_menu.cson'))
    }
    this.defM = CSON.load(path.join(__dirname, '../def', LOCALE, `menu_${process.platform}.cson`))
    this.defC = CSON.load(path.join(__dirname, '../def', LOCALE, 'context.cson'))
    this.defS = CSON.load(path.join(__dirname, '../def', LOCALE, 'settings.cson'))
    this.defA = CSON.load(path.join(__dirname, '../def', LOCALE, 'about.cson'))
    this.defW = CSON.load(path.join(__dirname, '../def', LOCALE, 'welcome.cson'))
  }
github liuderchi / atom-i18n / spec / validation.js View on Github external
describe(`checking "${path.join(locale, csonFile)}"`, () => {

              const cson = CSON.load(path.join(__dirname, '../def', locale, csonFile))
              const flattenCson = flattenObj(cson)

              it('has no error loading cson', () => {
                expect(cson).not.to.be.instanceof(Error, 'load cson error')
              })
              it('has consistent flatten keys with template', () => {
                expect(Object.keys(flattenCson)).to.deep.equal(templateKeys[csonFile], 'inconsistent keys')
              })
              it('has no special char in values of cson', () => {
                Object.keys(flattenCson).forEach(k => {
                  const specialChr = /[~@#%^*]/g
                  const _str = flattenCson[k].toString()
                  const _res = _str.search(specialChr)
                  const errMsg = `\n\tfound special chr: '${_str[_res]}' in value: '${_str}'\n\n\tcson-path: '${k}'\t`
                  expect(_res).to.equal(-1, errMsg)
                })
github liuderchi / atom-i18n / spec / validation.js View on Github external
CSON_FILES.forEach(csonFile => {
        templateKeys[csonFile] = Object.keys(flattenObj(CSON.load(path.join(__dirname, '../def/template', csonFile))))
      })

cson

CoffeeScript-Object-Notation Parser. Same as JSON but for CoffeeScript objects.

Artistic-2.0
Latest version published 10 months ago

Package Health Score

66 / 100
Full package analysis