Skip to content

Commit

Permalink
Some dep cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
swernerx committed Jul 25, 2018
1 parent d1cd42e commit 8eb6489
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 53 deletions.
82 changes: 38 additions & 44 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import fs from "fs-extra"
import { rollup } from "rollup"
import denodeify from "denodeify"
import rimraf from "rimraf"

import rebasePlugin from "../src"

const stat = denodeify(fs.stat)
const rimrafp = denodeify(rimraf)
const readFile = denodeify(fs.readFile)

const outputFolder = "./__tests__/output/"

function bundle(input, outputFile, pluginOptions = {}) {
Expand All @@ -26,19 +20,19 @@ function bundle(input, outputFile, pluginOptions = {}) {
}

function fileExists(name) {
return stat(name).then((result) => true, (error) => false)
return fs.stat(name).then((result) => true, (error) => false)
}

beforeAll(() => {
return rimrafp(outputFolder)
return fs.remove(outputFolder)
})

test("Plain", () => {
const outputFile = `${outputFolder}/plain/index.js`

return bundle("./__tests__/fixtures/plain.js", outputFile)
.then(() => Promise.all([ expect(fileExists(outputFile)).resolves.toBeTruthy() ]))
.then(Promise.all([ rimrafp(outputFile) ]))
.then(Promise.all([ fs.remove(outputFile) ]))
})


Expand All @@ -56,7 +50,7 @@ test("Assets", () => {
.then(() =>
Promise.all([
expect(fileExists(outputFile)).resolves.toBeTruthy(),
readFile(outputFile, "utf-8").then((content) => {
fs.readFile(outputFile, "utf-8").then((content) => {
expect(content).toMatchSnapshot()
}),
expect(fileExists(imageFile)).resolves.toBeTruthy(),
Expand All @@ -68,12 +62,12 @@ test("Assets", () => {
)
.then(
Promise.all([
rimrafp(outputFile),
rimrafp(imageFile),
rimrafp(fontFile),
rimrafp(deepFile),
rimrafp(cssFile),
rimrafp(cssFont)
fs.remove(outputFile),
fs.remove(imageFile),
fs.remove(fontFile),
fs.remove(deepFile),
fs.remove(cssFile),
fs.remove(cssFont)
])
)
})
Expand All @@ -95,7 +89,7 @@ test("Assets written to subfolder", () => {
.then(() =>
Promise.all([
expect(fileExists(outputFile)).resolves.toBeTruthy(),
readFile(outputFile, "utf-8").then((content) => {
fs.readFile(outputFile, "utf-8").then((content) => {
expect(content).toMatchSnapshot()
}),
expect(fileExists(imageFile)).resolves.toBeTruthy(),
Expand All @@ -107,12 +101,12 @@ test("Assets written to subfolder", () => {
)
.then(
Promise.all([
rimrafp(outputFile),
rimrafp(imageFile),
rimrafp(fontFile),
rimrafp(deepFile),
rimrafp(cssFile),
rimrafp(cssFont)
fs.remove(outputFile),
fs.remove(imageFile),
fs.remove(fontFile),
fs.remove(deepFile),
fs.remove(cssFile),
fs.remove(cssFont)
])
)
})
Expand All @@ -130,7 +124,7 @@ test("Outside Asset Source Location", () => {
.then(() =>
Promise.all([
expect(fileExists(outputFile)).resolves.toBeTruthy(),
readFile(outputFile, "utf-8").then((content) => {
fs.readFile(outputFile, "utf-8").then((content) => {
expect(content).toMatchSnapshot()
}),
expect(fileExists(imageFile)).resolves.toBeTruthy(),
Expand All @@ -142,12 +136,12 @@ test("Outside Asset Source Location", () => {
)
.then(
Promise.all([
rimrafp(outputFile),
rimrafp(imageFile),
rimrafp(fontFile),
rimrafp(deepFile),
rimrafp(cssFile),
rimrafp(cssFont)
fs.remove(outputFile),
fs.remove(imageFile),
fs.remove(fontFile),
fs.remove(deepFile),
fs.remove(cssFile),
fs.remove(cssFont)
])
)
})
Expand All @@ -165,7 +159,7 @@ test("Mixed Asset Source Locations", () => {
.then(() =>
Promise.all([
expect(fileExists(outputFile)).resolves.toBeTruthy(),
readFile(outputFile, "utf-8").then((content) => {
fs.readFile(outputFile, "utf-8").then((content) => {
expect(content).toMatchSnapshot()
}),
expect(fileExists(fontFile)).resolves.toBeTruthy(),
Expand All @@ -177,12 +171,12 @@ test("Mixed Asset Source Locations", () => {
)
.then(
Promise.all([
rimrafp(outputFile),
rimrafp(fontFile),
rimrafp(svgFile),
rimrafp(deepFile),
rimrafp(cssFile),
rimrafp(cssFont)
fs.remove(outputFile),
fs.remove(fontFile),
fs.remove(svgFile),
fs.remove(deepFile),
fs.remove(cssFile),
fs.remove(cssFont)
])
)
})
Expand All @@ -202,7 +196,7 @@ test("Keep Name", () => {
.then(() =>
Promise.all([
expect(fileExists(outputFile)).resolves.toBeTruthy(),
readFile(outputFile, "utf-8").then((content) => {
fs.readFile(outputFile, "utf-8").then((content) => {
expect(content).toMatchSnapshot()
}),
expect(fileExists(imageFile)).resolves.toBeTruthy(),
Expand All @@ -214,12 +208,12 @@ test("Keep Name", () => {
)
.then(
Promise.all([
rimrafp(outputFile),
rimrafp(imageFile),
rimrafp(fontFile),
rimrafp(deepFile),
rimrafp(cssFile),
rimrafp(cssFont)
fs.remove(outputFile),
fs.remove(imageFile),
fs.remove(fontFile),
fs.remove(deepFile),
fs.remove(cssFile),
fs.remove(cssFont)
])
)
})
5 changes: 0 additions & 5 deletions package-lock.json

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

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"lib/"
],
"scripts": {
"lint:js": "eslint --ignore-path .gitignore .",
"fix:js": "eslint --ignore-path .gitignore --fix .",
"format:js": "prettier --ignore-path .gitignore --write '**/*.{js,mjs}' && npm run fix:js",
"lint:js": "eslint .",
"fix:js": "eslint --fix .",
"format:js": "prettier --write '**/*.js' && npm run fix:js",
"release": "release-it --github.release --npm.publish --non-interactive",
"release:minor": "release-it --github.release --npm.publish --non-interactive --increment minor",
"release:major": "release-it --github.release --npm.publish --non-interactive --increment major",
Expand All @@ -48,7 +48,6 @@
"@babel/runtime": "^7.0.0-beta.54",
"asset-hash": "^2.1.2",
"core-js": "^2.5.7",
"denodeify": "^1.2.1",
"fs-extra": "^7.0.0",
"postcss": "^7.0.1",
"postcss-import": "^11.1.0",
Expand Down

0 comments on commit 8eb6489

Please sign in to comment.