fix(ui): folders on Windows

This commit is contained in:
Guillaume Chau
2018-06-19 00:12:52 +02:00
parent cebb2ffbe5
commit 4b44509e81
3 changed files with 26 additions and 18 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
"terminate": "^2.1.0",
"vue-cli-plugin-apollo": "^0.13.4",
"watch": "^1.0.2",
"winattr": "^2.0.0"
"@akryum/winattr": "^3.0.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.0.0-rc.3",
@@ -1,7 +1,7 @@
const path = require('path')
const fs = require('fs-extra')
const LRU = require('lru-cache')
const winattr = require('winattr')
const winattr = require('@akryum/winattr')
const hiddenPrefix = '.'
const isPlatformWindows = process.platform.indexOf('win') === 0
@@ -40,17 +40,25 @@ async function list (base, context) {
}
function isHidden (file) {
const prefixed = path.basename(file).charAt(0) === hiddenPrefix
const result = {
unix: prefixed,
windows: false
}
try {
const prefixed = path.basename(file).charAt(0) === hiddenPrefix
const result = {
unix: prefixed,
windows: false
}
if (isPlatformWindows) {
result.windows = winattr.getSync(file).hidden
}
if (isPlatformWindows) {
const windowsFile = file.replace(/\\/g, '\\\\')
result.windows = winattr.getSync(windowsFile).hidden
}
return (!isPlatformWindows && result.unix) || (isPlatformWindows && result.windows)
return (!isPlatformWindows && result.unix) || (isPlatformWindows && result.windows)
} catch (e) {
if (process.env.VUE_APP_CLI_UI_DEV) {
console.log('file:', file)
console.error(e)
}
}
}
function generateFolder (file, context) {
+7 -7
View File
@@ -2,6 +2,12 @@
# yarn lockfile v1
"@akryum/winattr@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@akryum/winattr/-/winattr-3.0.0.tgz#c345d49f8415583897e345729c12b3503927dd11"
dependencies:
fswin "^2.17.1227"
"@babel/code-frame@7.0.0-beta.44":
version "7.0.0-beta.44"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9"
@@ -5172,7 +5178,7 @@ fsevents@^1.0.0, fsevents@^1.1.2, fsevents@^1.2.3:
nan "^2.9.2"
node-pre-gyp "^0.10.0"
fswin@^2.16.1102:
fswin@^2.17.1227:
version "2.17.1227"
resolved "https://registry.yarnpkg.com/fswin/-/fswin-2.17.1227.tgz#c598061e1ac1e7110e2e6ce884296efa27dc2507"
@@ -12572,12 +12578,6 @@ win-fork@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/win-fork/-/win-fork-1.1.1.tgz#8f58e0656fca00adc8c86a2b89e3cd2d6a2d5e5e"
winattr@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/winattr/-/winattr-2.0.0.tgz#553d4e347c8c598551a8d7032eefe36526bd5026"
dependencies:
fswin "^2.16.1102"
window-size@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"