From 8b735258cf59a407dd308c8c9ed71011772a31f5 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 3 Oct 2015 20:50:12 +0700 Subject: [PATCH] cleanup --- .editorconfig | 2 +- .jshintrc | 13 ------------- .travis.yml | 2 +- package.json | 2 +- readme.md | 28 +++++++++++++--------------- test.js | 12 ++++++------ 6 files changed, 22 insertions(+), 37 deletions(-) delete mode 100644 .jshintrc diff --git a/.editorconfig b/.editorconfig index 86c8f59..8f9d77e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true -[package.json] +[{package.json,*.yml}] indent_style = space indent_size = 2 diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 804f8af..0000000 --- a/.jshintrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "node": true, - "esnext": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "immed": true, - "newcap": true, - "noarg": true, - "undef": true, - "unused": "vars", - "strict": true -} diff --git a/.travis.yml b/.travis.yml index dedfc07..52ba159 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: false language: node_js node_js: - - 'iojs' + - 'stable' - '0.12' - '0.10' diff --git a/package.json b/package.json index fd64d19..c0cd01d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" + "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" diff --git a/readme.md b/readme.md index 7c17c45..01f3963 100644 --- a/readme.md +++ b/readme.md @@ -5,7 +5,7 @@ ## Install -```sh +``` $ npm install --save temp-write ``` @@ -13,21 +13,21 @@ $ npm install --save temp-write ## Usage ```js -var fs = require('fs'); -var tempWrite = require('temp-write'); +const fs = require('fs'); +const tempWrite = require('temp-write'); -var filepath = tempWrite.sync('unicorn'); -//=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b +const filepath = tempWrite.sync('unicorn'); +//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b' fs.readFileSync(filepath, 'utf8'); -//=> unicorn +//=> 'unicorn' tempWrite.sync('unicorn', 'pony.png'); -//=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/pony.png +//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/pony.png' tempWrite.sync('unicorn', 'rainbow/cake/pony.png'); -//=> /var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/rainbow/cake/pony.png +//=> '/var/folders/_1/tk89k8215ts0rg0kmb096nj80000gn/T/4049f192-43e7-43b2-98d9-094e6760861b/rainbow/cake/pony.png' ``` @@ -37,23 +37,21 @@ tempWrite.sync('unicorn', 'rainbow/cake/pony.png'); Returns a promise that resolves to the filepath of the temp file. +### tempWrite.sync(input, [filepath]) + +Returns the filepath of the temp file. + #### input -*Required* Type: `string`, `buffer` #### filepath -Type: `string` +Type: `string` Example: `'img.png'`, `'foo/bar/baz.png'` Optionally supply a filepath which is appended to the random path. -### tempWrite.sync(input) - -Type: `string`, `buffer` -Returns: the filepath - ## Related diff --git a/test.js b/test.js index a22dca2..bbe7b16 100644 --- a/test.js +++ b/test.js @@ -1,10 +1,10 @@ import fs from 'fs'; -import test from 'ava'; import path from 'path'; -import tempWrite from './'; +import test from 'ava'; +import fn from './'; test('tempWrite(string)', async t => { - const filepath = await tempWrite('unicorn', 'test.png'); + const filepath = await fn('unicorn', 'test.png'); t.is(fs.readFileSync(filepath, 'utf8'), 'unicorn'); t.is(path.basename(filepath), 'test.png'); @@ -12,14 +12,14 @@ test('tempWrite(string)', async t => { }); test('tempWrite(buffer)', async t => { - const filepath = await tempWrite(new Buffer('unicorn'), 'test.png'); + const filepath = await fn(new Buffer('unicorn'), 'test.png'); t.is(fs.readFileSync(filepath, 'utf8'), 'unicorn'); t.end(); }); test('tempWrite(string, path)', async t => { - const filepath = await tempWrite(new Buffer('unicorn'), 'foo/bar/test.png'); + const filepath = await fn(new Buffer('unicorn'), 'foo/bar/test.png'); t.is(fs.readFileSync(filepath, 'utf8'), 'unicorn'); t.regexTest(/foo\/bar\/test\.png$/, filepath); @@ -27,6 +27,6 @@ test('tempWrite(string, path)', async t => { }); test('tempWrite.sync()', t => { - t.is(fs.readFileSync(tempWrite.sync('unicorn'), 'utf8'), 'unicorn'); + t.is(fs.readFileSync(fn.sync('unicorn'), 'utf8'), 'unicorn'); t.end(); });