Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit c2e42db

Browse files
committed
Changed fs-extra to fs-promise. Typo fix in readme.md
1 parent 73257ee commit c2e42db

File tree

5 files changed

+16
-60
lines changed

5 files changed

+16
-60
lines changed

bin/copy_source_files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const copy = require('./utils').copy;
3+
const copy = require('./utils').copyWithPattern;
44
const debug = require('./utils').debug;
55
const wrapAsync = require('./utils').wrapAsync;
66

bin/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const fs = require('fs-extra');
3+
const fs = require('fs-promise');
44
const path = require('path');
55
const Archiver = require('archiver');
66
const isValidConfig = require('./is_valid_config');

bin/utils.js

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const fs = require('fs-extra');
3+
const fs = require('fs-promise');
44
const spawn = require('child-process-promise').spawn;
55
const glob = require('glob');
66
const path = require('path');
@@ -66,18 +66,18 @@ const asyncGlob = (pattern, opts) => new Promise(
6666
);
6767

6868
/**
69-
* @func copy
70-
* @desc Copies multiple files snychronously from one dir to another according to a glob pattern specified
69+
* @func copyWithPattern
70+
* @desc Copies multiple files asynchronously from one dir to another according to a glob pattern specified
7171
* @param {string} cwd - The path to search for file(s) at
7272
* @param {string} pattern - A glob pattern to match the file(s)
7373
* @param {string} dest - The destination dir path
7474
* @return {Promise}
7575
*/
76-
const copy = (cwd, pattern, dest) => wrapAsync(function*() {
76+
const copyWithPattern = (cwd, pattern, dest) => wrapAsync(function*() {
7777
const files = yield asyncGlob(pattern, {cwd: cwd});
7878
if (files.length === 0) debug('patternlab→util→copy: Nothing to copy');
7979
// Copy concurrently
80-
const promises = files.map(file => copyAsync(
80+
const promises = files.map(file => fs.copy(
8181
path.join(cwd, file),
8282
path.join(dest, file))
8383
);
@@ -126,57 +126,13 @@ const checkAndInstallPackage = (packageName, url) => wrapAsync(function*() {
126126
*/
127127
const noop = () => {};
128128

129-
/**
130-
* Promisified helper functions based on fs-extra
131-
* 1. copyAsync
132-
* 2. mkdirsAsync
133-
* 3. moveAsync
134-
* 4. writeJsonAsync
135-
* 5. readJsonAsync
136-
*/
137-
138-
const copyAsync = (src, target) => new Promise((resolve, reject) => {
139-
fs.copy(src, target, function (err) {
140-
if (err) return reject(err);
141-
return resolve();
142-
})
143-
});
144-
145-
const mkdirsAsync = dir => new Promise((resolve, reject) => {
146-
fs.mkdirs(dir, function (err) {
147-
if (err) return reject(err);
148-
return resolve();
149-
})
150-
});
151-
152-
const moveAsync = (dir, target) => new Promise((resolve, reject) => {
153-
fs.move(dir, target, function (err) {
154-
if (err) return reject(err);
155-
return resolve();
156-
})
157-
});
158-
159-
const writeJsonAsync = (file, data) => new Promise((resolve, reject) => {
160-
fs.outputJson(file, data, function (err) {
161-
if (err) return reject(err);
162-
return resolve();
163-
});
164-
});
165-
166-
const readJsonAsync = file => new Promise((resolve, reject) => {
167-
fs.readJson(file, function (err, data) {
168-
if (err) return reject(err);
169-
return resolve(data);
170-
});
171-
});
172-
173129
module.exports = {
174-
copy,
175-
copyAsync,
176-
mkdirsAsync,
177-
moveAsync,
178-
writeJsonAsync,
179-
readJsonAsync,
130+
copyWithPattern,
131+
copyAsync: fs.copy,
132+
mkdirsAsync: fs.mkdirs,
133+
moveAsync: fs.move,
134+
writeJsonAsync: fs.outputJson,
135+
readJsonAsync: fs.readJson,
180136
error,
181137
debug,
182138
wrapAsync,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"child-process-promise": "2.2.0",
1717
"colors": "1.1.2",
1818
"commander": "2.9.0",
19-
"fs-extra": "1.0.0",
19+
"fs-promise": "1.0.0",
2020
"glob": "7.1.1",
2121
"inquirer": "1.2.3",
2222
"lodash": "4.17.1",

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Coming soon …
77

88
## Usage
9-
```bash
9+
```
1010
Usage: patternlab <cmd> [options]
1111
Commands:
1212
build|compile [options] Build the PatternLab. Optionally (re-)build only the patterns
@@ -20,7 +20,7 @@ Usage: patternlab <cmd> [options]
2020
-c, --config <path> Specify config file. Default looks up the project dir
2121
```
2222
## Examples
23-
```bash
23+
```
2424
$ patternlab init # Initialize a PatternLab project.
2525
$ patternlab <cmd> # Builds the PatternLab from the current dir
2626
$ patternlab <cmd> --config <path/to/patternlab-config> # PatternLab from a config in a specified directory

0 commit comments

Comments
 (0)