fix(core): update

This commit is contained in:
Philipp Kunz 2020-03-15 18:58:46 +00:00
parent d8f4b011b7
commit c7f800fc88
6 changed files with 17 additions and 15 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -24,13 +24,14 @@ mirror:
- docker - docker
- notpriv - notpriv
snyk: audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=moderate
tags: tags:
- lossless - lossless
- docker - docker

View File

@ -52,7 +52,8 @@
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",

View File

@ -32,7 +32,6 @@ smartfile thinks in sections:
| interpreter | (object) handles yaml and json | | interpreter | (object) handles yaml and json |
| smartfile | (class) a virtual representation of a file, alternative to vinyl file format | | smartfile | (class) a virtual representation of a file, alternative to vinyl file format |
## Contribution ## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -201,7 +201,7 @@ export const toStringSync = (filePath: string): string => {
export const toBufferSync = (filePath: string): Buffer => { export const toBufferSync = (filePath: string): Buffer => {
return plugins.fsExtra.readFileSync(filePath); return plugins.fsExtra.readFileSync(filePath);
} };
export const fileTreeToHash = async (dirPathArg: string, miniMatchFilter: string) => { export const fileTreeToHash = async (dirPathArg: string, miniMatchFilter: string) => {
const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter); const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter);

View File

@ -25,11 +25,11 @@ export interface IToFsOptions {
* @param fileBaseArg * @param fileBaseArg
*/ */
export let toFs = async ( export let toFs = async (
fileContentArg: string | Smartfile, fileContentArg: string | Buffer | Smartfile,
filePathArg, filePathArg: string,
optionsArg: IToFsOptions = {} optionsArg: IToFsOptions = {}
) => { ) => {
let done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
// check args // check args
if (!fileContentArg || !filePathArg) { if (!fileContentArg || !filePathArg) {
@ -38,23 +38,26 @@ export let toFs = async (
// prepare actual write action // prepare actual write action
let fileString: string; let fileString: string;
let fileEncoding: string = 'utf8';
let filePath: string = filePathArg; let filePath: string = filePathArg;
// handle Smartfile // handle Smartfile
if (fileContentArg instanceof Smartfile) { if (fileContentArg instanceof Smartfile) {
let fileContentArg2: any = fileContentArg;
fileString = fileContentArg.contentBuffer.toString(); fileString = fileContentArg.contentBuffer.toString();
// handle options // handle options
if (optionsArg.respectRelative) { if (optionsArg.respectRelative) {
filePath = plugins.path.join(filePath, fileContentArg.path); filePath = plugins.path.join(filePath, fileContentArg.path);
} }
} else if (Buffer.isBuffer(fileContentArg)) {
fileString = fileContentArg.toString('binary');
fileEncoding = 'binary';
} else if (typeof fileContentArg === 'string') { } else if (typeof fileContentArg === 'string') {
fileString = fileContentArg; fileString = fileContentArg;
} else { } else {
throw new Error('fileContent is neither string nor Smartfile'); throw new Error('fileContent is neither string nor Smartfile');
} }
await smartfileFs.ensureDir(plugins.path.parse(filePath).dir); await smartfileFs.ensureDir(plugins.path.parse(filePath).dir);
plugins.fsExtra.writeFile(filePath, fileString, { encoding: 'utf8' }, done.resolve); plugins.fsExtra.writeFile(filePath, fileString, { encoding: fileEncoding }, done.resolve);
return await done.promise; return await done.promise;
}; };