mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-03 23:09:17 -05:00
refactor: replace mkdirp with fs.mkdir(Sync) (#2217)
This commit is contained in:
parent
84373c4669
commit
1b217fd346
10 changed files with 11703 additions and 10513 deletions
11
.changeset/gentle-parrots-lay.md
Normal file
11
.changeset/gentle-parrots-lay.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
'@verdaccio/config': minor
|
||||
'@verdaccio/local-storage': minor
|
||||
'@verdaccio/e2e-ui': minor
|
||||
---
|
||||
|
||||
Some verdaccio modules depend on 'mkdirp' library which provides recursive directory creation functionality.
|
||||
NodeJS can do this out of the box since v.10.12. The last commit in 'mkdirp' was made in early 2016, and it's mid 2021 now.
|
||||
Time to stick with a built-in library solution!
|
||||
|
||||
- All 'mkdirp' calls are replaced with appropriate 'fs' calls.
|
|
@ -45,7 +45,6 @@
|
|||
"js-yaml": "3.14.0",
|
||||
"lodash": "^4.17.20",
|
||||
"minimatch": "3.0.4",
|
||||
"mkdirp": "0.5.5",
|
||||
"yup": "^0.29.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -2,7 +2,6 @@ import fs from 'fs';
|
|||
import path from 'path';
|
||||
import Path from 'path';
|
||||
import _ from 'lodash';
|
||||
import mkdirp from 'mkdirp';
|
||||
import buildDebug from 'debug';
|
||||
|
||||
import { CHARACTER_ENCODING } from '@verdaccio/commons-api';
|
||||
|
@ -67,7 +66,7 @@ export function readDefaultConfig(): Buffer {
|
|||
}
|
||||
|
||||
function createConfigFolder(configLocation): void {
|
||||
mkdirp.sync(Path.dirname(configLocation.path));
|
||||
fs.mkdirSync(Path.dirname(configLocation.path), { recursive: true });
|
||||
debug(`Creating default config file in %o`, configLocation?.path);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,7 @@
|
|||
"async": "^3.2.0",
|
||||
"debug": "^4.1.1",
|
||||
"lodash": "^4.17.20",
|
||||
"lowdb": "1.0.0",
|
||||
"mkdirp": "^0.5.5"
|
||||
"lowdb": "1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/minimatch": "^3.0.3",
|
||||
|
|
|
@ -4,7 +4,6 @@ import buildDebug from 'debug';
|
|||
|
||||
import _ from 'lodash';
|
||||
import async from 'async';
|
||||
import mkdirp from 'mkdirp';
|
||||
import {
|
||||
Callback,
|
||||
Config,
|
||||
|
@ -276,10 +275,9 @@ class LocalDatabase extends TokenActions implements IPluginStorage<{}> {
|
|||
}
|
||||
// Uses sync to prevent ugly race condition
|
||||
try {
|
||||
// https://www.npmjs.com/package/mkdirp#mkdirpsyncdir-opts
|
||||
const folderName = Path.dirname(this.path);
|
||||
debug('creating folder %o', folderName);
|
||||
mkdirp.sync(folderName);
|
||||
fs.mkdirSync(folderName, { recursive: true });
|
||||
debug('sync folder %o created succeed', folderName);
|
||||
} catch (err) {
|
||||
debug('sync create folder has failed with error: %o', err);
|
||||
|
|
|
@ -5,7 +5,6 @@ import path from 'path';
|
|||
import buildDebug from 'debug';
|
||||
|
||||
import _ from 'lodash';
|
||||
import mkdirp from 'mkdirp';
|
||||
import { UploadTarball, ReadTarball } from '@verdaccio/streams';
|
||||
import { unlockFile, readFile } from '@verdaccio/file-locking';
|
||||
import { Callback, Logger, Package, ILocalPackageManager, IUploadTarball } from '@verdaccio/types';
|
||||
|
@ -353,7 +352,7 @@ export default class LocalFS implements ILocalFSPackageManager {
|
|||
|
||||
createTempFile((err) => {
|
||||
if (err && err.code === noSuchFile) {
|
||||
mkdirp(path.dirname(dest), function (err) {
|
||||
fs.mkdir(path.dirname(dest), { recursive: true }, function (err) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
import mkdirp from 'mkdirp';
|
||||
import rm from 'rmdir-sync';
|
||||
import { Logger, ILocalPackageManager, Package } from '@verdaccio/types';
|
||||
|
||||
|
@ -113,7 +112,7 @@ describe('Local FS test', () => {
|
|||
|
||||
describe('removePackage() group', () => {
|
||||
beforeEach(() => {
|
||||
mkdirp.sync(path.join(localTempStorage, '_toDelete'));
|
||||
fs.mkdirSync(path.join(localTempStorage, '_toDelete'), { recursive: true });
|
||||
});
|
||||
|
||||
test('removePackage() success', (done) => {
|
||||
|
@ -183,7 +182,7 @@ describe('Local FS test', () => {
|
|||
beforeEach(() => {
|
||||
const writeTarballFolder: string = path.join(localTempStorage, '_writeTarball');
|
||||
rm(writeTarballFolder);
|
||||
mkdirp.sync(writeTarballFolder);
|
||||
fs.mkdirSync(writeTarballFolder, { recursive: true });
|
||||
});
|
||||
|
||||
test('writeTarball() success', (done) => {
|
||||
|
|
22182
pnpm-lock.yaml
generated
22182
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -9,7 +9,6 @@
|
|||
"kleur": "^4.1.3",
|
||||
"request": "^2.88.2",
|
||||
"lodash": "^4.17.20",
|
||||
"mkdirp": "^1.0.4",
|
||||
"rimraf": "^3.0.2",
|
||||
"puppeteer": "^7.1.0"
|
||||
},
|
||||
|
|
|
@ -3,7 +3,6 @@ const os = require('os');
|
|||
const path = require('path');
|
||||
|
||||
const { green } = require('kleur');
|
||||
const mkdirp = require('mkdirp');
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
const DIR = path.join(os.tmpdir(), 'jest_puppeteer_global_setup');
|
||||
|
@ -21,6 +20,6 @@ module.exports = async function () {
|
|||
args: ['--no-sandbox'],
|
||||
});
|
||||
global.__BROWSER__ = browser;
|
||||
mkdirp.sync(DIR);
|
||||
fs.mkdirSync(DIR, { recursive: true });
|
||||
fs.writeFileSync(path.join(DIR, 'wsEndpoint'), browser.wsEndpoint());
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue