Skip to content

Commit

Permalink
Rename from xo-init to create-xo
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
sindresorhus committed Sep 26, 2019
1 parent 1ba26be commit f3b381a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
31 changes: 15 additions & 16 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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`.

Expand Down Expand Up @@ -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 [<options>]`.
12 changes: 4 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ 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;

async function run(pkg) {
const filepath = tempWrite.sync(JSON.stringify(pkg), 'package.json');

await xoInit({
await createXo({
cwd: path.dirname(filepath),
skipInstall: true
});
Expand Down Expand Up @@ -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/);
});

0 comments on commit f3b381a

Please sign in to comment.