no-shot / env
Showing 2 of 9 files from the diff.

@@ -33,43 +33,15 @@
Loading
33 33
  const { env } = process;
34 34
  const { LOAD_CONFIG } = env;
35 35
36 -
  let dir: ConfigOptions["dir"];
37 -
  let paths: ConfigOptions["paths"];
38 -
  let debug: ConfigOptions["debug"];
39 -
  let encoding: ConfigOptions["encoding"];
40 -
  let override: ConfigOptions["override"];
41 -
42 36
  // checks if LOAD_CONFIG is defined and assigns config options
43 37
  if (LOAD_CONFIG) {
44 38
    const envConfig = load(LOAD_CONFIG);
45 39
46 -
    if (Object.keys(envConfig).length) {
47 -
      dir = envConfig.dir;
48 -
      paths = envConfig.paths;
49 -
      debug = envConfig.debug;
50 -
      encoding = envConfig.encoding;
51 -
      override = envConfig.override;
52 -
    }
40 +
    if (Object.keys(envConfig).length) config(envConfig);
53 41
54 42
    // prevents the IFFE from reloading the config file
55 43
    delete process.env.LOAD_CONFIG;
56 44
  }
57 -
58 -
  const { ENV_DIR, ENV_LOAD, ENV_DEBUG, ENV_ENCODE, ENV_OVERRIDE } = env;
59 -
60 -
  // checks if ENV_LOAD is defined and automatically calls config with Env variables
61 -
  if (ENV_LOAD || paths) {
62 -
    config({
63 -
      dir: ENV_DIR || dir,
64 -
      paths: ENV_LOAD || paths,
65 -
      debug: ENV_DEBUG || debug,
66 -
      encoding: (ENV_ENCODE || encoding) as BufferEncoding,
67 -
      override: ENV_OVERRIDE || override
68 -
    });
69 -
70 -
    // prevents the IFFE from reloading the .env files
71 -
    delete process.env.ENV_LOAD;
72 -
  }
73 45
})();
74 46
75 47
export { assign, config, load, parse };

@@ -26,8 +26,10 @@
Loading
26 26
  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 27
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
 */
29 +
import { readFileSync } from "fs";
29 30
import { execSync } from "child_process";
30 31
import { logWarning } from "../log";
32 +
import fileExists from "../fileExists";
31 33
import type { Option, ParsedEnvs } from "../index";
32 34
33 35
/**
@@ -100,8 +102,29 @@
Loading
100 102
101 103
  // loops over key value pairs
102 104
  for (let i = 0; i < keyValues.length; i += 1) {
105 +
    const VAL = keyValues[i];
103 106
    // finds matching "KEY' and 'VAL' in 'KEY=VAL'
104 -
    const keyValueArr = keyValues[i].match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
107 +
    let keyValueArr = VAL.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/);
108 +
109 +
    // finds matching '# extends: path/to/.env'
110 +
    if (!keyValueArr) {
111 +
      keyValueArr = keyValues[i].match(/(?<=# extends: ).*/g);
112 +
113 +
      // checks if there's a matching extension
114 +
      if (Array.isArray(keyValueArr)) {
115 +
        let extended = {};
116 +
        const [envPath] = keyValueArr;
117 +
        // if the file exists, parse it...
118 +
        if (fileExists(envPath))
119 +
          extended = parse(readFileSync(envPath), override);
120 +
121 +
        // and assign it to extracted
122 +
        Object.assign(extracted, extended);
123 +
124 +
        // remove extension value
125 +
        keyValueArr = null;
126 +
      }
127 +
    }
105 128
106 129
    if (keyValueArr) {
107 130
      const key = keyValueArr[1];
Files Coverage
assign/index.ts 100.00%
config/index.ts 100.00%
fileExists/index.ts 100.00%
getFilePath/index.ts 100.00%
index.ts 100.00%
load/index.ts 100.00%
log/index.ts 100.00%
parse/index.ts 100.00%
Project Totals (8 files) 100.00%
Notifications are pending CI completion. Periodically Codecov will check the CI state, when complete notifications will be submitted. Push notifications now.

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading