Skip to content

Commit

Permalink
Tests: Normalize path separators for globby results (stylelint#2293)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesemashko committed Mar 3, 2017
1 parent 3b47a84 commit a1f7ed2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/__tests__/standalone-cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ const fsExtra = require("fs-promise")
const fileExists = require("file-exists-promise")

const cwd = process.cwd()
const invalidFile = path.normalize(`${fixturesPath}/empty-block.css`)
const validFile = path.normalize(`${fixturesPath}/cache/valid.css`)
const newFileDest = path.normalize(`${fixturesPath}/cache/newFile.css`)
const invalidFile = path.join(fixturesPath, "empty-block.css")
const validFile = path.join(fixturesPath, "cache", "valid.css")
const newFileDest = path.join(fixturesPath, "cache", "newFile.css")

// Config object is getting mutated internally.
// Return new object of the same structure to
// make sure config doesn't change between runs.
function getConfig() {
return {
files: `${fixturesPath}/cache/*.css`,
files: path.join(fixturesPath, "cache", "*.css"),
config: {
rules: { "block-no-empty": true, "color-no-invalid-hex": true },
},
Expand All @@ -26,7 +26,7 @@ function getConfig() {
}

describe("standalone cache", () => {
const expectedCacheFilePath = `${cwd}/.stylelintcache`
const expectedCacheFilePath = path.join(cwd, ".stylelintcache")

beforeEach(() => {
// Initial run to warm up the cache
Expand Down Expand Up @@ -121,9 +121,9 @@ describe("standalone cache", () => {
})
})
describe("standalone cache uses cacheLocation", () => {
const cacheLocationFile = `${fixturesPath}/cache/.cachefile`
const cacheLocationDir = `${fixturesPath}/cache/`
const expectedCacheFilePath = `${cacheLocationDir}/.stylelintcache_${hash(cwd)}`
const cacheLocationFile = path.join(fixturesPath, "cache", ".cachefile")
const cacheLocationDir = path.join(fixturesPath, "cache")
const expectedCacheFilePath = path.join(cacheLocationDir, `.stylelintcache_${hash(cwd)}`)
afterEach(() => {
// clean up after each test
return Promise.all([
Expand Down
3 changes: 1 addition & 2 deletions lib/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ module.exports = function (options/*: Object */)/*: Promise<stylelint$standalone
let absoluteFilePaths = filePaths.map(filePath => {
const absoluteFilepath = (!path.isAbsolute(filePath))
? path.join(process.cwd(), filePath)
: filePath

: path.normalize(filePath)
return absoluteFilepath
})

Expand Down

0 comments on commit a1f7ed2

Please sign in to comment.