Ejemplo n.º 1
0
const format = answers => {
  const scope = answers.scope
    ? `(${R.trim(answers.scope)})`
    : ''

  const head = R.concat(
    `${answers.type}${scope}: `,
    R.trim(answers.subject)
  )

  const comment = answers.comment
    ? 'comment: ' + answers.comment
    : undefined

  const transition = answers.transition
    ? 'transition: ' + answers.transition
    : undefined

  /* apply breaking change prefix, removing it if already present */
  let breaking = answers.breaking
    ? R.trim(answers.breaking)
    : ''

  breaking = breaking
    ? 'BREAKING CHANGE: ' +
      breaking.replace(/^BREAKING CHANGE: /, '')
    : ''

  breaking = wrap(breaking, {
    trim: true,
    newline: '\n',
    indent: '',
    width: 100
  })

  const rawCommit = [
    comment,
    `spent: ${answers.time}`,
    `issue: #${answers.issues}`,
    transition
  ]

  /* prettier-ignore */
  const body = R.pipe(
    R.reject(R.isNil), 
    R.join('\n\n')
  )(rawCommit)

  const commit = `${head}\n\n${body}\n\n${breaking}`

  console.log(answers.time, answers.issues)

  return postSpentTime({
    issueId: answers.issues,
    duration: answers.time
  })
    .then(R.concat('total time contribution so far: '))
    .then(console.log)
    .then(R.always(commit))
}
Ejemplo n.º 2
0
const execScript = async (script, options) => {
  if (is(Function, script)) {
    return script()
  }
  const [ command, ...args ] = split(' ', trim(script))
  return spawnCommand(command, args, options)
}
Ejemplo n.º 3
0
 renderString () {
   const { value } = this.props
   return (
     <div>
       {map(this.breakIntoSpans, split('\n', trim(value)))}
     </div>
   )
 }
  components.forEach((component) => {

    // Replace all spaces and words after last number. Any space before numbers replace with _.
    let currentComponent = R.trim(component.name.replace(/\s([a-zA-Z])+/g, '')).replace(/[\s]+/g, '_');

    if (R.isEmpty(componentsNames)) {
      componentsNames = currentComponent;

    } else {
      componentsNames += ':' + currentComponent;
    }
  });
Ejemplo n.º 5
0
  gitinfo.getHeadSha = (): string => {
    let sha;

    const branch = gitinfo.getBranchName();
    const shaFile = path.join(gitPath, 'refs', 'heads', branch);

    try {
      sha = fs.readFileSync(shaFile, {encoding: 'utf8'});
    } catch (err) {
            /* istanbul ignore next */
      throw new Error('Cannot read the commit SHA of the current HEAD from the ' + shaFile + '.\n' + err);
    }

    return R.trim(sha);
  };
Ejemplo n.º 6
0
export function parseNumerosRestriccion(jsonArray) {
  const getNumbers =
          compose(
            filter(Number.isInteger),
            map(parseInt));

  const parseNumbers =
          compose(
            getNumbers,
            split('-'),
            replace(/ /g, '-'),
            trim());

  const conSelloRegex = replace(/.*, con sello verde(.*)/, '$1');
  const sinSelloRegex = replace(/^.*sin sello verde.*? (\d[\d- ]*)(,.*)?$/, '$1');
  const fechaRegex = /.*\b(\d{1,2}) de .*:.*/;
  const exceptionsPredicates = [
    test(noAplicaPattern),
    test(noRigePattern),
    test(sinRestriccionPattern)
  ];

  const parseSinSello =
    ifElse( anyPass(exceptionsPredicates),
      always([]), compose(parseNumbers, sinSelloRegex) );


  const parseConSello =
    ifElse(test(/^.*, con sello verde (.*)$/),
      compose(parseNumbers, conSelloRegex), always([]));


  if(!(fechaRegex.test(jsonArray[0]))) {
    throw Error("Couldn't get 'fecha' while scraping");
  }

  const day = jsonArray[0].replace(fechaRegex, '$1');

  return {
    fecha  : getDate(day),
    estatus: jsonArray[1],
    numeros: {
      sinSello: parseSinSello(jsonArray[0]),
      conSello: parseConSello(jsonArray[0])
    }
  };
}
Ejemplo n.º 7
0
		const _parse = (src) => {
			const lines = R.split('\n')
			const match = R.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/)
			const matches = R.map(match)
			const getMatchs = R.compose(matches, lines)
			const replaceQuotes = R.replace(/(^['"]|['"]$)/g, '')
			const trim = R.trim()
			const getValue = (item) => {
				const v = item[2] ? item[2] : ''
				const value = R.compose(trim, replaceQuotes)(v)
				const object = {}
				object[item[1]] = value
				return object
			}
			const filter = R.filter(n => n.length > 0)
			const map = R.compose(R.map(getValue), filter, getMatchs)
			return R.compose(R.mergeAll, map)(src)
		}
Ejemplo n.º 8
0
 it("should trim", () => {
   const s: string = _.trim("s");
 });
Ejemplo n.º 9
0
 [{keyword:$, text:$, location: $}, function (k,t,l) {
     var tk = R.trim(k);
     acc['last'] = tk;
     acc[tk] = [{'text':modifyText(t), 'original': R.trim(t), 'location':l}];
     return acc;
 }]
Ejemplo n.º 10
0
 [{keyword:function (x) {return 'And' === R.trim(x)}, text:$, location: $}, function (t,l) {
     var nxt = R.append({'text':modifyText(t), 'original': R.trim(t), 'location':l},acc[acc['last']]);
     return R.assoc(acc.last,nxt,acc);
 }],
Ejemplo n.º 11
0
 [{keyword:function (x) {return 'And' === R.trim(x)}, text:$, location: $}, function (t,l) {
Ejemplo n.º 12
0
 css[image_name] = R.map(style => R.trim(style).split(':'), el.find('.bar').attr('style').split(';'));
Ejemplo n.º 13
0
// text: output of command "git tag"
function sortTagsByVersion (text) {
  const tags = R.reject(R.isEmpty, R.map(R.trim, R.split('\n', R.trim(text))))
  return tags.sort(semver.compare)
}
Ejemplo n.º 14
0
/**
 * Install this module.
 *
 * @param {Object} context         The gluegun context
 * @param {Object} opts            The options used to install
 * @param {string} opts.moduleName The module to install
 */
async function importPlugin (context, opts) {
  const { moduleName, type, directory } = opts
  const { ignite, system, filesystem } = context
  const { log } = ignite
  const isDirectory = type === 'directory'
  const target = isDirectory ? directory : moduleName

  // check to see if it exists first
  if (type === 'npm') {
    try {
      const json = JSON.parse(await system.run(`npm info ${target} --json`))
      log(`${json.name} ${json.version} on npm.`)
    } catch (e) {
      log(`unable to find ${target} on npm`)
      const boom = new Error(e.message)
      boom.unavailable = true
      boom.name = target
      throw boom
    }
  }

  if (ignite.useYarn) {
    if (isDirectory) {
      // where is the yarn cache?
      log(`checking for yarn cache`)
      const rawCacheDir = await system.exec('yarn cache dir')

      // look for a cached version of this
      const dirs = filesystem
        .cwd(rawCacheDir)
        .find({
          matching: `npm-${moduleName}-*`,
          directories: true,
          recursive: false
        })

      // clear existing cache if we have one
      if (!isEmpty(dirs)) {
        forEach(
          dir => {
            log(`removing yarn cache ${rawCacheDir}/${dir}`)
            filesystem.remove(`${rawCacheDir}/${dir}`)
          },
          dirs
        )
      }
    }
    
    const cmd = isDirectory
      ? `yarn add file:${target} --force --dev`
      : `yarn add ${target} --dev`
    log(cmd)
    await system.run(cmd)
    log('finished yarn command')
  } else {
    const cacheBusting = isDirectory ? '--cache-min=0' : ''
    const cmd = trim(`npm i ${target} --save-dev ${cacheBusting}`)
    log(cmd)
    await system.run(cmd)
    log('finished npm command')
  }
}
Ejemplo n.º 15
0
const validate = val => {
  const trimmedValue = R.is(String, val) ? R.trim(val) : val;

  return required.validate(trimmedValue);
};
Ejemplo n.º 16
0
		R.map(R.trim),
		R.when(
			R.propEq('length', 1),
			R.prepend(undefined)
		),
		R.zipObj(['name', 'type'])
	))
)
	
const parseCases = R.pipe(
	R.split('}'),
	R.head(),
	R.split(/\scase/),
	R.tail(), // Remove initial `enum ... {`
	R.map(R.pipe(
		R.trim(),
		R.match(/([^(]+)(\([\s\S]+\))?/),
		R.tail,
		R.over(R.lensIndex(1), parseAssociated),
		R.zipObj(['name', 'associated'])
	))
)

const parseEnum = R.converge(
	(name, cases) => ({
		name,
		cases
	}), [
		parseName,
		parseCases
	]
Ejemplo n.º 17
0
var makeSignal = xs => "$event => document.body.dispatchEvent(new CustomEvent(" + R.trim(R.head(xs)) + ",{detail:" + (R.join("", R.tail(xs)) || 'null') + "}))";