Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Upgrade all dependencies #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/test-ws
/npm-debug.log
/test.js
/.idea
6 changes: 3 additions & 3 deletions bin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const Watcher = require("../lib/utils/watcher")
// Helpers
//------------------------------------------------------------------------------

const ABS_OR_REL = /^[./]/
const C_OR_COMMAND = /^(?:-c|--command)$/
const T_OR_TRANSFORM = /^(?:-t|--transform)$/
const ABS_OR_REL = /^[./]/u
const C_OR_COMMAND = /^(?:-c|--command)$/u
const T_OR_TRANSFORM = /^(?:-t|--transform)$/u

//------------------------------------------------------------------------------
// Exports
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/normalize-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ module.exports = function normalizePath(originalPath) {

const cwd = process.cwd()
const relativePath = path.resolve(originalPath)
const normalizedPath = path.relative(cwd, relativePath).replace(/\\/g, "/")
const normalizedPath = path.relative(cwd, relativePath).replace(/\\/gu, "/")

if (/\/$/.test(normalizedPath)) {
if (/\/$/u.test(normalizedPath)) {
return normalizedPath.slice(0, -1)
}
return normalizedPath || "."
Expand Down
22 changes: 11 additions & 11 deletions lib/utils/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ const removeFile = require("./remove-file")
// Helpers
//------------------------------------------------------------------------------

const walkDirectories = co.wrap(function*(root, dereference, callback) {
const walkDirectories = co.wrap(function*(rootPath, dereference, callback) {
const stack = []

// Check whether the root is a directory.
{
const stat = yield fs.stat(root)
const stat = yield fs.stat(rootPath)
if (!stat.isDirectory()) {
return
}
stack.push({
path: root,
path: rootPath,
files: new Map(),
})
}
Expand Down Expand Up @@ -159,14 +159,14 @@ module.exports = class Watcher extends EventEmitter {

/**
* Start watching the files of the given directory.
* @param {string} root The path to the root directory to watch.
* @param {string} rootPath The path to the root directory to watch.
* @returns {Promise<void>} The promise which will go fulfilled after done.
* @private
*/
addDirectory(root) {
debug("Watcher#addDirectory", root)
addDirectory(rootPath) {
debug("Watcher#addDirectory", rootPath)
return walkDirectories(
root,
rootPath,
this.dereference,
co.wrap(
function*(dirPath, files) {
Expand Down Expand Up @@ -244,13 +244,13 @@ module.exports = class Watcher extends EventEmitter {

/**
* Stop watching the files of the given directory.
* @param {string} root The path to the root directory to watch.
* @param {string} rootPath The path to the root directory to watch.
* @returns {void}
* @private
*/
removeDirectory(root) {
debug("Watcher#removeDirectory", root)
const stack = [root]
removeDirectory(rootPath) {
debug("Watcher#removeDirectory", rootPath)
const stack = [rootPath]
const eventStack = []

while (stack.length > 0) {
Expand Down
43 changes: 22 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,37 @@
"postversion": "git push && git push --tags",
"pretest": "npm run -s lint",
"preversion": "npm test",
"test": "nyc --require babel-register npm run -s _mocha",
"watch": "npm run -s _mocha -- --require babel-register --watch --growl"
"test": "nyc --require @babel/register npm run -s _mocha",
"watch": "npm run -s _mocha -- --require @babel/register --watch --growl"
},
"dependencies": {
"co": "^4.6.0",
"debounce": "^1.1.0",
"debug": "^3.1.0",
"debounce": "^1.2.0",
"debug": "^4.1.1",
"duplexer": "^0.1.1",
"fs-extra": "^6.0.1",
"glob": "^7.1.2",
"fs-extra": "^8.1.0",
"glob": "^7.1.6",
"glob2base": "0.0.12",
"minimatch": "^3.0.4",
"resolve": "^1.8.1",
"safe-buffer": "^5.1.2",
"shell-quote": "^1.6.1",
"resolve": "^1.13.1",
"safe-buffer": "^5.2.0",
"shell-quote": "^1.7.2",
"subarg": "^1.0.0"
},
"devDependencies": {
"@mysticatea/eslint-plugin": "^5.0.1",
"babel-preset-power-assert": "^2.0.0",
"babel-register": "^6.26.0",
"codecov": "^3.0.2",
"eslint": "^5.0.1",
"mocha": "^5.2.0",
"nyc": "12.0.2",
"opener": "^1.4.3",
"p-event": "^2.0.0",
"power-assert": "^1.6.0",
"rimraf": "^2.6.2",
"shelljs": "^0.8.2",
"@babel/core": "^7.0.0",
"@babel/register": "^7.0.0",
"@mysticatea/eslint-plugin": "^13.0.0",
"babel-preset-power-assert": "^3.0.0",
"codecov": "^3.6.1",
"eslint": "^6.7.2",
"mocha": "^6.2.2",
"nyc": "14.1.1",
"opener": "^1.5.1",
"p-event": "^4.1.0",
"power-assert": "^1.6.1",
"rimraf": "^3.0.0",
"shelljs": "^0.8.3",
"through": "^2.3.8"
},
"repository": {
Expand Down
20 changes: 13 additions & 7 deletions test/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe("The copy method", () => {
"test-ws/a/b/this-is.txt": "A pen",
"test-ws/a/b/that-is.txt": "A note",
"test-ws/a/b/no-copy.dat": "no-copy",
}))
})
)
afterEach(() => teardownTestDir("test-ws"))

/**
Expand Down Expand Up @@ -87,7 +88,8 @@ describe("The copy method", () => {
"test-ws/a/b/no-copy.dat": "no-copy",
"test-ws/b/b/remove.txt": "remove",
"test-ws/b/b/no-remove.dat": "no-remove",
}))
})
)
afterEach(() => teardownTestDir("test-ws"))

/**
Expand Down Expand Up @@ -231,7 +233,8 @@ describe("The copy method", () => {
"test-ws/a/hello.txt": "Hello",
"test-ws/a/b/pen.txt": "A pen",
"test-ws/a/c": null,
}))
})
)
afterEach(() => teardownTestDir("test-ws"))

/**
Expand Down Expand Up @@ -279,7 +282,8 @@ describe("The copy method", () => {
"test-ws/a/hello.txt": "Hello",
"test-ws/a/b/pen.txt": "A pen",
"test-ws/a/c": null,
}))
})
)
afterEach(() => teardownTestDir("test-ws"))

/**
Expand All @@ -295,7 +299,7 @@ describe("The copy method", () => {
"test-ws/b/b/pen.txt": "A pen",
})
assert(fs.statSync("test-ws/a/c").isDirectory())
assert.throws(() => fs.statSync("test-ws/b/c"), /ENOENT/)
assert.throws(() => fs.statSync("test-ws/b/c"), /ENOENT/u)
})
}

Expand Down Expand Up @@ -324,7 +328,8 @@ describe("The copy method", () => {
"test-ws/a/b/this-is.txt": "A pen",
"test-ws/a/b/that-is.txt": "A note",
"test-ws/a/b/no-copy.dat": "no-copy",
}))
})
)
afterEach(() => teardownTestDir("test-ws"))

/**
Expand Down Expand Up @@ -673,7 +678,8 @@ describe("The copy method", () => {

describe("should copy specified files with globs even if there are parentheses:", () => {
beforeEach(() =>
setupTestDir({ "test-ws/a(paren)/hello.txt": "Hello" }))
setupTestDir({ "test-ws/a(paren)/hello.txt": "Hello" })
)
afterEach(() => teardownTestDir("test-ws"))

/**
Expand Down
12 changes: 6 additions & 6 deletions test/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,41 @@ describe("[misc]", () => {
const result = execCommandSync("")

assert(result.code === 1)
assert(/Usage:/.test(result.stdout))
assert(/Usage:/u.test(result.stdout))
})

it("should throw error and show help if <dest> was lacking.", () => {
const result = execCommandSync("test-ws/**/*.js")

assert(result.code === 1)
assert(/Usage:/.test(result.stdout))
assert(/Usage:/u.test(result.stdout))
})

it("should show help if --help option was given.", () => {
const result = execCommandSync("--help")

assert(result.code === 0)
assert(/Usage:/.test(result.stdout))
assert(/Usage:/u.test(result.stdout))
})

it("should show help if -h option was given.", () => {
const result = execCommandSync("--help")

assert(result.code === 0)
assert(/Usage:/.test(result.stdout))
assert(/Usage:/u.test(result.stdout))
})

it("should show version if --version option was given.", () => {
const result = execCommandSync("--version")

assert(result.code === 0)
assert(/^v[0-9]+\.[0-9]+\.[0-9]+\n$/.test(result.stdout))
assert(/^v[0-9]+\.[0-9]+\.[0-9]+\n$/u.test(result.stdout))
})

it("should show version if -V option was given.", () => {
const result = execCommandSync("-V")

assert(result.code === 0)
assert(/^v[0-9]+\.[0-9]+\.[0-9]+\n$/.test(result.stdout))
assert(/^v[0-9]+\.[0-9]+\.[0-9]+\n$/u.test(result.stdout))
})
})
17 changes: 9 additions & 8 deletions test/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,10 @@ const readFile = (module.exports.content = function content(path) {
*/
module.exports.setupTestDir = function setupTestDir(dataset) {
return Promise.all(
Object.keys(dataset).map(
path =>
dataset[path] == null
? fs.ensureDir(path)
: writeFile(path, dataset[path])
Object.keys(dataset).map(path =>
dataset[path] == null
? fs.ensureDir(path)
: writeFile(path, dataset[path])
)
).then(() => delay(250))
}
Expand All @@ -101,7 +100,7 @@ module.exports.teardownTestDir = function teardownTestDir(testRootPath) {
module.exports.verifyTestDir = co.wrap(function* verifyTestDir(dataset) {
for (const path of Object.keys(dataset)) {
const content = yield readFile(path)
assert.equal(content, dataset[path])
assert.strictEqual(content, dataset[path])
}
})

Expand All @@ -111,7 +110,7 @@ module.exports.verifyTestDir = co.wrap(function* verifyTestDir(dataset) {
* @returns {child_process.ChildProcess} A child process object.
*/
module.exports.execCommand = function execCommand(args) {
return exec(`node test/util/bin.js ${args}`)
return exec(`${process.execPath} test/util/bin.js ${args}`)
}

/**
Expand All @@ -120,5 +119,7 @@ module.exports.execCommand = function execCommand(args) {
* @returns {void}
*/
module.exports.execCommandSync = function execCommandSync(args) {
return execSync(`node test/util/bin.js ${args}`, { silent: true })
return execSync(`${process.execPath} test/util/bin.js ${args}`, {
silent: true,
})
}
Loading