コード例 #1
0
'use strict'

const pkg = require('../../package.json')
const configLoader = require('@blinkmobile/blinkmrc')

const projectConfig = configLoader.projectConfig({name: pkg.name})
const userConfig = configLoader.userConfig({name: pkg.name})

module.exports = {
  project: {
    read: () => projectConfig.load(),
    write: (updater) => projectConfig.update(updater)
  },
  user: {
    read: () => userConfig.load(),
    write: (updater) => userConfig.update(updater)
  }
}
コード例 #2
0
'use strict';

const configLoader = require('@blinkmobile/blinkmrc');
const projectConfig = configLoader.projectConfig();

const privateVars = new WeakMap();
const DEFAULT = 'default';

/**
 * Manages the project's .blinkmrc.json file's "project" setting
 */
class ProfileManager {
  constructor () {
    privateVars.set(this, {profileName: DEFAULT});
  }

  /**
   * The profile name in use
   * @default  default
   * @return {string} profile name
   */
  get name () {
    return privateVars.get(this).profileName;
  }

  /**
   * Reads the project name from the projects .blinkmrc.json
   * @default  {Promise<string>} Resolves with 'default'
   * @return {Promise<string>} Resolves with the profile name
   */
  read () {