Skip to content

Commit

Permalink
Merge pull request #78 from TheWolfNL/master
Browse files Browse the repository at this point in the history
Fix for working in subdir
  • Loading branch information
okonet authored Oct 17, 2016
2 parents 1535afb + 86391f1 commit c095272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ cosmiconfig('lint-staged', {
// result.filepath is the path to the config file that was found
const config = result.config
const concurrent = config.concurrent || true

const gitDir = path.resolve(config.gitDir) || process.cwd()

// If gitDir is defined -> set git root as sgf's cwd
if ('gitDir' in config) {
sgf.cwd = path.resolve(config.gitDir)
if (gitDir != process.cwd()) {
sgf.cwd = gitDir
}

sgf('ACM', (err, files) => {
if (err) {
console.error(err)
}

const tasks = generateTasks(config, resolvePaths(files))
const tasks = generateTasks(config, resolvePaths(files, gitDir))
.map(task => ({
title: `Running tasks for ${ task.pattern }`,
task: () => (new Listr(runScript(task.commands, task.fileList, packageJson)))
Expand Down
2 changes: 1 addition & 1 deletion src/resolvePaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const path = require('path')
module.exports = function resolvePaths(filePaths, relativeTo) {
return filePaths.map((file) => {
if (!relativeTo) relativeTo = process.cwd() // eslint-disable-line
return path.resolve(process.cwd(), relativeTo, file.filename)
return path.resolve(path.relative( process.cwd(), relativeTo), file.filename)
})
}

0 comments on commit c095272

Please sign in to comment.