From c7f800fc88bb4d78e655e31bd945db132083718e Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Sun, 15 Mar 2020 18:58:46 +0000 Subject: [PATCH] fix(core): update --- .gitignore | 4 +--- .gitlab-ci.yml | 7 ++++--- package.json | 5 +++-- readme.md | 1 - ts/smartfile.fs.ts | 2 +- ts/smartfile.memory.ts | 13 ++++++++----- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 91c0db0..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ node_modules/ # builds dist/ -dist_web/ -dist_serve/ -dist_ts_web/ +dist_*/ # custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a95dfb6..d0c0adc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,13 +24,14 @@ mirror: - docker - notpriv -snyk: - image: registry.gitlab.com/hosttoday/ht-docker-node:snyk +audit: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - npmci npm prepare - 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: - lossless - docker diff --git a/package.json b/package.json index f4f59d0..e64d253 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,12 @@ "ts/**/*", "ts_web/**/*", "dist/**/*", - "dist_web/**/*", + "dist_*/**/*", + "dist_ts/**/*", "dist_ts_web/**/*", "assets/**/*", "cli.js", "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/readme.md b/readme.md index 4e782ec..0516e3d 100644 --- a/readme.md +++ b/readme.md @@ -32,7 +32,6 @@ smartfile thinks in sections: | interpreter | (object) handles yaml and json | | smartfile | (class) a virtual representation of a file, alternative to vinyl file format | - ## 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). :) diff --git a/ts/smartfile.fs.ts b/ts/smartfile.fs.ts index 604592a..71799b9 100644 --- a/ts/smartfile.fs.ts +++ b/ts/smartfile.fs.ts @@ -201,7 +201,7 @@ export const toStringSync = (filePath: string): string => { export const toBufferSync = (filePath: string): Buffer => { return plugins.fsExtra.readFileSync(filePath); -} +}; export const fileTreeToHash = async (dirPathArg: string, miniMatchFilter: string) => { const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter); diff --git a/ts/smartfile.memory.ts b/ts/smartfile.memory.ts index d699385..0635246 100644 --- a/ts/smartfile.memory.ts +++ b/ts/smartfile.memory.ts @@ -25,11 +25,11 @@ export interface IToFsOptions { * @param fileBaseArg */ export let toFs = async ( - fileContentArg: string | Smartfile, - filePathArg, + fileContentArg: string | Buffer | Smartfile, + filePathArg: string, optionsArg: IToFsOptions = {} ) => { - let done = plugins.smartpromise.defer(); + const done = plugins.smartpromise.defer(); // check args if (!fileContentArg || !filePathArg) { @@ -38,23 +38,26 @@ export let toFs = async ( // prepare actual write action let fileString: string; + let fileEncoding: string = 'utf8'; let filePath: string = filePathArg; // handle Smartfile if (fileContentArg instanceof Smartfile) { - let fileContentArg2: any = fileContentArg; fileString = fileContentArg.contentBuffer.toString(); // handle options if (optionsArg.respectRelative) { filePath = plugins.path.join(filePath, fileContentArg.path); } + } else if (Buffer.isBuffer(fileContentArg)) { + fileString = fileContentArg.toString('binary'); + fileEncoding = 'binary'; } else if (typeof fileContentArg === 'string') { fileString = fileContentArg; } else { throw new Error('fileContent is neither string nor Smartfile'); } 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; };