fix(core): update
This commit is contained in:
parent
d8f4b011b7
commit
c7f800fc88
4
.gitignore
vendored
4
.gitignore
vendored
@ -15,8 +15,6 @@ node_modules/
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -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
|
||||
|
@ -52,7 +52,8 @@
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
|
@ -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). :)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user