Skip to content

Commit

Permalink
Made it not depend on fs-extra.
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Sep 14, 2018
1 parent e183302 commit 2a60285
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
26 changes: 0 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint:fix": "eslint . --fix",
"test:sp": "mocha \"test_sp/**/*.js\" --reporter dot",
"test:v:node6": "npm run test:v:high && npm run test:v:latest && npm i",
"test:v:node4": "npm i babel-eslint@8 fs-extra@5 --no-save && npm run test:v:low && npm i",
"test:v:node4": "npm i babel-eslint@8 --no-save && npm run test:v:low && npm i",
"test:v:high": "npm i eslint@5.0.0 parse5@5.0.0 --no-save && npm run test:base",
"test:v:low": "npm i eslint@4.15.0 parse5@4.0.0 --no-save && npm run test:base",
"test:v:latest": "npm i eslint@latest parse5@latest --no-save && npm run test:base",
Expand Down Expand Up @@ -62,7 +62,6 @@
"babel-eslint": "^9.0.0",
"eslint": "^5.3.0",
"eslint-plugin-local": "^1.0.0",
"fs-extra": "^7.0.0",
"if-node-version": "^1.1.1",
"mocha": "^5.2.0",
"nyc": "^13.0.1",
Expand All @@ -71,8 +70,5 @@
"dependencies": {
"esquery": "^1.0.0",
"parse5": "^4.0.0 || ^5.0.0"
},
"greenkeeper": {
"ignore": []
}
}
28 changes: 24 additions & 4 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const assert = require("assert")
const path = require("path")
const eslint = require("eslint")
const fs = require("fs-extra")
const fs = require("fs")
const plugin = require("..")

const CLIEngine = eslint.CLIEngine
Expand All @@ -12,6 +12,25 @@ const ORIGINAL_FIXTURE_DIR = path.join(__dirname, "fixtures")
const FIXTURE_DIR = path.join(__dirname, "temp")
const CONFIG_PATH = path.join(ORIGINAL_FIXTURE_DIR, "test.eslintrc.js")

/**
* Remove dir
* @param {string} dirPath dir path
* @returns {void}
*/
function removeDirSync(dirPath) {
if (fs.existsSync(dirPath)) {
for (const file of fs.readdirSync(dirPath)) {
const curPath = `${dirPath}/${file}`
if (fs.lstatSync(curPath).isDirectory()) {
removeDirSync(curPath)
} else {
fs.unlinkSync(curPath)
}
}
fs.rmdirSync(dirPath)
}
}

/**
* Assert the messages
* @param {Array} actual The actual messages
Expand Down Expand Up @@ -70,18 +89,19 @@ describe("index test", () => {

describe("Basic tests", () => {
beforeEach(() => {
fs.emptyDirSync(FIXTURE_DIR)
removeDirSync(FIXTURE_DIR)
fs.mkdirSync(FIXTURE_DIR)
for (const fileName of fs.readdirSync(ORIGINAL_FIXTURE_DIR)) {
const src = path.join(ORIGINAL_FIXTURE_DIR, fileName)
const dst = path.join(FIXTURE_DIR, fileName)

if (fs.statSync(src).isFile()) {
fs.copySync(src, dst)
fs.writeFileSync(dst, fs.readFileSync(src))
}
}
})
afterEach(() => {
fs.removeSync(FIXTURE_DIR)
removeDirSync(FIXTURE_DIR)
})

describe("About fixtures/hello.html", () => {
Expand Down

0 comments on commit 2a60285

Please sign in to comment.