Compare commits

...

10 Commits

Author SHA1 Message Date
d5c2d167ec 5.0.0 2022-03-16 16:10:47 +01:00
2af6d5a974 4.0.18 2022-03-16 16:10:09 +01:00
fdba21d60d 4.0.17 2022-03-16 16:09:25 +01:00
c17ebca309 fix(core): update 2022-03-16 16:09:24 +01:00
a014dcf1ab 4.0.16 2020-10-13 20:09:15 +00:00
44bee7bf6f fix(core): update 2020-10-13 20:09:15 +00:00
7841917058 4.0.15 2020-09-29 19:29:51 +00:00
f5a674f98d fix(core): update 2020-09-29 19:29:50 +00:00
80ece7c093 4.0.14 2020-09-29 19:10:00 +00:00
39250b3d47 fix(core): update 2020-09-29 19:10:00 +00:00
7 changed files with 15117 additions and 7661 deletions

View File

@ -9,7 +9,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartenv",
"shortDescription": "store things about your environment and let them travel across modules",
"description": "store things about your environment and let them travel across modules",
"npmPackagename": "@pushrocks/smartenv",
"license": "MIT"
}

22643
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,13 @@
{
"name": "@pushrocks/smartenv",
"version": "4.0.13",
"version": "5.0.0",
"description": "store things about your environment and let them travel across modules",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web && tsbundle npm)",
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
"testbrowser": "(npm test) && (node testbrowser.js)"
},
"repository": {
@ -23,17 +24,16 @@
},
"homepage": "https://gitlab.com/pushrocks/smartenv",
"dependencies": {
"@pushrocks/smartparam": "^1.1.6",
"@pushrocks/smartpromise": "^3.0.6",
"@types/node": "^14.11.2"
"@pushrocks/smartpromise": "^3.1.7",
"@types/node": "^17.0.21"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
"@types/npm": "^2.0.31",
"@gitzone/tsbuild": "^2.1.56",
"@gitzone/tsbundle": "^1.0.98",
"@gitzone/tsrun": "^1.2.31",
"@gitzone/tstest": "^1.0.68",
"@pushrocks/tapbundle": "^5.0.2",
"@types/npm": "^7.19.0",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},

View File

@ -1,5 +1,5 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartenv from '../ts/index';
import * as smartenv from '../ts/index.js';
let testEnv: smartenv.Smartenv;
@ -17,20 +17,20 @@ tap.test('should get os', async () => {
const resultWindows = await testEnv.isWindowsAsync();
const osModule = await import('os');
if (resultMac) {
expect(osModule.platform()).to.equal('darwin');
expect(osModule.platform()).toEqual('darwin');
console.log('platform is Mac!');
} else if (resultLinux) {
expect(osModule.platform()).to.equal('linux');
expect(osModule.platform()).toEqual('linux');
console.log('platform is Linux!');
} else {
expect(osModule.platform()).to.equal('win32');
expect(osModule.platform()).toEqual('win32');
console.log('platform is Windows!');
}
});
tap.test('should state wether we are in CI', async () => {
if (process.env.CI) {
expect(testEnv.isCI).to.be.true;
expect(testEnv.isCI).toBeTrue();
}
});

View File

@ -1 +1 @@
export * from './smartenv.classes.smartenv';
export * from './smartenv.classes.smartenv.js';

View File

@ -1,5 +1,5 @@
import * as plugins from './smartenv.plugins';
import * as interfaces from './interfaces';
import * as plugins from './smartenv.plugins.js';
import * as interfaces from './interfaces/index.js';
// interfaces
export interface IEnvObject {
@ -26,20 +26,13 @@ export class Smartenv {
}
}
public getSafeNodeModule<T = any>(moduleNameArg: string): T {
public async getSafeNodeModule<T = any>(moduleNameArg: string): Promise<T> {
if (!this.isNode) {
console.error('You tried to load a node module in a wrong context');
return;
}
// tslint:disable-next-line: function-constructor
return new Function(
'exports',
'require',
'module',
'__filename',
'__dirname',
`return require('${moduleNameArg}')`
)(exports, require, module, __filename, __dirname);
return (new Function(`return import('${moduleNameArg}')`))() as Promise<T>;
}
public loadedScripts: string[] = [];
@ -50,7 +43,7 @@ export class Smartenv {
}
if (this.loadedScripts.includes(urlArg)) {
return;
return getFunctionArg();
} else {
this.loadedScripts.push(urlArg);
}
@ -114,7 +107,7 @@ export class Smartenv {
public async isMacAsync(): Promise<boolean> {
if (this.isNode) {
const os = this.getSafeNodeModule('os');
const os = await this.getSafeNodeModule('os');
return os.platform() === 'darwin';
} else {
return false;
@ -123,7 +116,7 @@ export class Smartenv {
public async isWindowsAsync(): Promise<boolean> {
if (this.isNode) {
const os = this.getSafeNodeModule('os');
const os = await this.getSafeNodeModule('os');
return os.platform() === 'win32';
} else {
return false;
@ -132,30 +125,21 @@ export class Smartenv {
public async isLinuxAsync(): Promise<boolean> {
if (this.isNode) {
const os = this.getSafeNodeModule('os');
const os = await this.getSafeNodeModule('os');
return os.platform() === 'linux';
} else {
return false;
}
}
/**
* get environment variables that fit the description
*/
// get envVars (regexArg: RegExp) {
// let EnvironmentArray = []
// // TODO: plugins.smartparam.forEachMinimatch()
// }
/**
* prints the environment to console
*/
public async printEnv() {
if (this.isNode) {
console.log('running on NODE');
const smartenvVersion = require('../package.json').version;
console.log(
'node version is ' + this.nodeVersion + ' and smartenv version is ' + smartenvVersion
'node version is ' + this.nodeVersion
);
} else {
console.log('running on BROWSER');

View File

@ -1,4 +1,3 @@
import * as smartparam from '@pushrocks/smartparam';
import * as smartpromise from '@pushrocks/smartpromise';
export { smartparam, smartpromise };
export { smartpromise };