File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1+ const { join } = require ( 'path' )
12const fs = require ( 'fs-extra' )
23const git = require ( 'simple-git/promise' )
34const throwError = require ( './utils/throw-error' )
5+ const isChildPathOf = require ( './utils/is-child-path-of' )
46
57
68const isEmpty = async path => {
@@ -17,8 +19,13 @@ const reminder = [
1719
1820const isWorkDirClean = async path => {
1921 const { files } = await git ( path ) . status ( )
20-
21- return ! files . length
22+ let toplevel = await git ( path ) . revparse ( [ '--show-toplevel' ] )
23+ toplevel = toplevel . replace ( / \n $ / , '' )
24+
25+ return ! files
26+ . map ( file => join ( toplevel , file . path ) )
27+ . filter ( isChildPathOf ( path ) )
28+ . length
2229}
2330
2431module . exports = async path => {
Original file line number Diff line number Diff line change 1+ module . exports = parent => child => {
2+ if ( child === parent ) return false
3+ const parentTokens = parent . split ( '/' ) . filter ( i => i . length )
4+ const childTokens = child . split ( '/' ) . filter ( i => i . length )
5+ return parentTokens . every ( ( t , i ) => childTokens [ i ] === t )
6+ }
You can’t perform that action at this time.
0 commit comments