不要怂,就是干,撸起袖子干!

Commit 6837a174 by Andrew Vereshchak Committed by Pedro Augusto de Paula Barbosa

fix(sqlite): moving 'fs-jetpack' back to devDependencies (#11861)

using recursive 'fs.mkdirSync()' instead of 'jetpack.dir()'
1 parent cfc9685b
'use strict'; 'use strict';
const fs = require('fs');
const path = require('path'); const path = require('path');
const jetpack = require('fs-jetpack');
const AbstractConnectionManager = require('../abstract/connection-manager'); const AbstractConnectionManager = require('../abstract/connection-manager');
const Promise = require('../../promise'); const Promise = require('../../promise');
const { logger } = require('../../utils/logger'); const { logger } = require('../../utils/logger');
...@@ -59,7 +59,8 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -59,7 +59,8 @@ class ConnectionManager extends AbstractConnectionManager {
} }
if (!options.inMemory && (options.readWriteMode & this.lib.OPEN_CREATE) !== 0) { if (!options.inMemory && (options.readWriteMode & this.lib.OPEN_CREATE) !== 0) {
jetpack.dir(path.dirname(options.storage)); // automatic path provision for `options.storage` // automatic path provision for `options.storage`
fs.mkdirSync(path.dirname(options.storage), { recursive: true });
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
...@@ -1635,7 +1635,8 @@ ...@@ -1635,7 +1635,8 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
}, },
"base": { "base": {
"version": "0.11.2", "version": "0.11.2",
...@@ -1750,6 +1751,7 @@ ...@@ -1750,6 +1751,7 @@
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
...@@ -2285,7 +2287,8 @@ ...@@ -2285,7 +2287,8 @@
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
...@@ -4142,6 +4145,7 @@ ...@@ -4142,6 +4145,7 @@
"version": "2.2.3", "version": "2.2.3",
"resolved": "https://registry.npmjs.org/fs-jetpack/-/fs-jetpack-2.2.3.tgz", "resolved": "https://registry.npmjs.org/fs-jetpack/-/fs-jetpack-2.2.3.tgz",
"integrity": "sha512-MldfoKMz2NwpvP3UFfVXLp4NCncy9yxGamgBK6hofFaisnWoGvgkAyTtKwcq++leztgZuM4ywrZEaUtiyVfWgA==", "integrity": "sha512-MldfoKMz2NwpvP3UFfVXLp4NCncy9yxGamgBK6hofFaisnWoGvgkAyTtKwcq++leztgZuM4ywrZEaUtiyVfWgA==",
"dev": true,
"requires": { "requires": {
"minimatch": "^3.0.2", "minimatch": "^3.0.2",
"rimraf": "^2.6.3" "rimraf": "^2.6.3"
...@@ -4169,7 +4173,8 @@ ...@@ -4169,7 +4173,8 @@
"fs.realpath": { "fs.realpath": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
}, },
"function-bind": { "function-bind": {
"version": "1.1.1", "version": "1.1.1",
...@@ -4348,6 +4353,7 @@ ...@@ -4348,6 +4353,7 @@
"version": "7.1.6", "version": "7.1.6",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
"dev": true,
"requires": { "requires": {
"fs.realpath": "^1.0.0", "fs.realpath": "^1.0.0",
"inflight": "^1.0.4", "inflight": "^1.0.4",
...@@ -4907,6 +4913,7 @@ ...@@ -4907,6 +4913,7 @@
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": { "requires": {
"once": "^1.3.0", "once": "^1.3.0",
"wrappy": "1" "wrappy": "1"
...@@ -4915,7 +4922,8 @@ ...@@ -4915,7 +4922,8 @@
"inherits": { "inherits": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
...@@ -6522,6 +6530,7 @@ ...@@ -6522,6 +6530,7 @@
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
...@@ -10917,6 +10926,7 @@ ...@@ -10917,6 +10926,7 @@
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
...@@ -11151,7 +11161,8 @@ ...@@ -11151,7 +11161,8 @@
"path-is-absolute": { "path-is-absolute": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
}, },
"path-is-inside": { "path-is-inside": {
"version": "1.0.2", "version": "1.0.2",
...@@ -11835,6 +11846,7 @@ ...@@ -11835,6 +11846,7 @@
"version": "2.7.1", "version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
"dev": true,
"requires": { "requires": {
"glob": "^7.1.3" "glob": "^7.1.3"
} }
...@@ -13726,7 +13738,8 @@ ...@@ -13726,7 +13738,8 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
}, },
"write": { "write": {
"version": "1.0.3", "version": "1.0.3",
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
"bluebird": "^3.7.1", "bluebird": "^3.7.1",
"debug": "^4.1.1", "debug": "^4.1.1",
"dottie": "^2.0.0", "dottie": "^2.0.0",
"fs-jetpack": "^2.2.3",
"inflection": "1.12.0", "inflection": "1.12.0",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"moment": "^2.24.0", "moment": "^2.24.0",
...@@ -65,6 +64,7 @@ ...@@ -65,6 +64,7 @@
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-plugin-jsdoc": "^4.1.1", "eslint-plugin-jsdoc": "^4.1.1",
"eslint-plugin-mocha": "^6.2.2", "eslint-plugin-mocha": "^6.2.2",
"fs-jetpack": "^2.2.3",
"husky": "^1.3.1", "husky": "^1.3.1",
"js-combinatorics": "^0.5.5", "js-combinatorics": "^0.5.5",
"lcov-result-merger": "^3.0.0", "lcov-result-merger": "^3.0.0",
......
...@@ -8,13 +8,14 @@ const dialect = Support.getTestDialect(); ...@@ -8,13 +8,14 @@ const dialect = Support.getTestDialect();
const DataTypes = require('../../../../lib/data-types'); const DataTypes = require('../../../../lib/data-types');
const fileName = `${Math.random()}_test.sqlite`; const fileName = `${Math.random()}_test.sqlite`;
const folderName = `${Math.random()}_test_folder`; const directoryName = `${Math.random()}_test_directory`;
const nestedFileName = jetpack.path(directoryName, 'subdirectory', 'test.sqlite');
if (dialect === 'sqlite') { if (dialect === 'sqlite') {
describe('[SQLITE Specific] Connection Manager', () => { describe('[SQLITE Specific] Connection Manager', () => {
after(() => { after(() => {
jetpack.remove(fileName); jetpack.remove(fileName);
jetpack.remove(folderName); jetpack.remove(directoryName);
}); });
it('close connection and remove journal and wal files', function() { it('close connection and remove journal and wal files', function() {
...@@ -49,11 +50,10 @@ if (dialect === 'sqlite') { ...@@ -49,11 +50,10 @@ if (dialect === 'sqlite') {
}); });
it('automatic path provision for `options.storage`', () => { it('automatic path provision for `options.storage`', () => {
const p = jetpack.path(folderName, fileName); return Support.createSequelizeInstance({ storage: nestedFileName })
return Support.createSequelizeInstance({ storage: p })
.define('User', { username: DataTypes.STRING }) .define('User', { username: DataTypes.STRING })
.sync({ force: true }).then(() => { .sync({ force: true }).then(() => {
expect(jetpack.exists(p)).to.be.equal('file'); expect(jetpack.exists(nestedFileName)).to.be.equal('file');
}); });
}); });
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!