Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3eb4b8d
commit b3dbc23
Showing
6 changed files
with
77 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
|
||
const getBaseName = (name) => path.basename(name, path.extname(name)); | ||
|
||
module.exports = (obj) => { | ||
const result = {}; | ||
|
||
Object | ||
.keys(obj) | ||
.forEach((key) => { | ||
result[getBaseName(key)] = obj[key]; | ||
}); | ||
|
||
return result; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const isDev = process.NODE_ENV === 'development'; | ||
const dir = getDirPath(isDev); | ||
const readFilesSync = require('./read-files-sync'); | ||
const basenameKeys = require('./basename-keys'); | ||
|
||
module.exports = { | ||
const defaultColumns = { | ||
'': '', | ||
'name-size-date': fs.readFileSync(`${dir}/name-size-date.css`, 'utf8'), | ||
'name-size-date-owner-mode': '', | ||
}; | ||
|
||
function getDirPath (isDev) { | ||
const dist = isDev ? 'dist-dev' : 'dist'; | ||
return `${__dirname}/../${dist}/columns`; | ||
} | ||
const isDev = process.NODE_ENV === 'development'; | ||
const getDist = (isDev) => isDev ? 'dist-dev' : 'dist'; | ||
|
||
const dist = getDist(isDev); | ||
const columnsDir = path.join(__dirname, '..', dist, 'columns'); | ||
const columnsNames = fs.readdirSync(columnsDir); | ||
const columns = readFilesSync(columnsDir, columnsNames, 'utf8'); | ||
|
||
module.exports = Object.assign( | ||
basenameKeys(columns), | ||
defaultColumns, | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'uses strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const currify = require('currify/legacy'); | ||
|
||
const readSync = currify((mode, name) => fs.readFileSync(name, 'utf8')); | ||
const join = currify((dir, name) => path.join(dir, name)); | ||
const bindNames = currify((fn, array, value, i) => fn(array[i], value)); | ||
|
||
const objectify = (key, value) => ({ | ||
[key]: value | ||
}); | ||
|
||
module.exports = (dir, names, mode) => { | ||
const columns = names | ||
.map(join(dir)) | ||
.map(readSync(mode)) | ||
.map(bindNames(objectify, names)); | ||
|
||
return Object.assign.apply(null, columns) | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const join = require('path').join; | ||
const path = require('path'); | ||
const readFilesSync = require('./read-files-sync'); | ||
const basenameKeys = require('./basename-keys'); | ||
const squad = require('squad/legacy'); | ||
|
||
const DIR = __dirname + '/../'; | ||
const DIR_TMPL = DIR + 'tmpl/'; | ||
const DIR_FS = DIR_TMPL + 'fs/'; | ||
const templatePath = path.join(__dirname, '..', 'tmpl/fs'); | ||
const templateNames = fs.readdirSync(templatePath); | ||
const readTemplates = squad(basenameKeys, readFilesSync); | ||
|
||
const TMPL_PATH = [ | ||
'file', | ||
'panel', | ||
'path', | ||
'pathLink', | ||
'link', | ||
]; | ||
|
||
module.exports = () => { | ||
const templates = {}; | ||
|
||
TMPL_PATH.forEach((name) => { | ||
const path = join(DIR_FS, `${name}.hbs`); | ||
templates[name] = fs.readFileSync(path, 'utf8'); | ||
}); | ||
|
||
return templates; | ||
}; | ||
module.exports = readTemplates(templatePath, templateNames, 'utf8'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters