Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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, ''))
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();
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
}
}
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'))
}
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'))
}
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'))
}
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'))
}
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)
})
CSON_FILES.forEach(csonFile => {
templateKeys[csonFile] = Object.keys(flattenObj(CSON.load(path.join(__dirname, '../def/template', csonFile))))
})