diff --git a/package.json b/package.json index 2807ace..8849709 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "xo-init", + "name": "create-xo", "version": "0.7.0", "description": "Add XO to your project", "license": "MIT", - "repository": "xojs/xo-init", + "repository": "xojs/create-xo", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", diff --git a/readme.md b/readme.md index c494c02..3039a57 100644 --- a/readme.md +++ b/readme.md @@ -1,30 +1,34 @@ -# xo-init [![Build Status](https://travis-ci.org/xojs/xo-init.svg?branch=master)](https://travis-ci.org/xojs/xo-init) +# create-xo [![Build Status](https://travis-ci.org/xojs/create-xo.svg?branch=master)](https://travis-ci.org/xojs/create-xo) > Add [XO](https://github.com/xojs/xo) to your project -## Install +## CLI ``` -$ npm install xo-init +$ npm init xo [options] ``` +Example: + +``` +$ npm init xo --space --no-semicolon +``` + + +## API -## Usage +### Usage ```js -const xoInit = require('xo-init'); +const createXo = require('create-xo'); (async () => { - await xoInit(); - console.log('Done'); + await createXo(); })(); ``` - -## API - -### xoInit(options?) +### createXo(options?) Returns a `Promise`. @@ -59,8 +63,3 @@ For instance, with the arguments `['--space', '--env=node']` the following will } } ``` - - -## CLI - -Install XO globally `$ npm install --global xo` and run `$ xo --init []`. diff --git a/test.js b/test.js index ae3586a..727491b 100644 --- a/test.js +++ b/test.js @@ -3,11 +3,7 @@ import fs from 'fs'; import tempWrite from 'temp-write'; import dotProp from 'dot-prop'; import test from 'ava'; -import xoInit from '.'; - -// Remove --color flag passed on from AVA -// TODO: Remove this when fixed in AVA -process.argv = process.argv.filter(x => x !== '--color'); +import createXo from '.'; const originalArgv = process.argv.slice(); const {get} = dotProp; @@ -15,7 +11,7 @@ const {get} = dotProp; async function run(pkg) { const filepath = tempWrite.sync(JSON.stringify(pkg), 'package.json'); - await xoInit({ + await createXo({ cwd: path.dirname(filepath), skipInstall: true }); @@ -161,12 +157,12 @@ test('has everything covered when it comes to config', async t => { test('installs the XO dependency', async t => { const filepath = tempWrite.sync(JSON.stringify({}), 'package.json'); - await xoInit({cwd: path.dirname(filepath)}); + await createXo({cwd: path.dirname(filepath)}); t.truthy(get(JSON.parse(fs.readFileSync(filepath, 'utf8')), 'devDependencies.xo')); }); test('installs via yarn if there\'s a lockfile', async t => { const yarnLock = tempWrite.sync('', 'yarn.lock'); - await xoInit({cwd: path.dirname(yarnLock)}); + await createXo({cwd: path.dirname(yarnLock)}); t.regex(fs.readFileSync(yarnLock, 'utf8'), /xo/); });