Skip to content

Commit

Permalink
* (bluefox) Added support for vis-2 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Apr 10, 2024
1 parent 32cb3a0 commit 1f192d7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46

## Changelog
<!-- ### **WORK IN PROGRESS** -->
### **WORK IN PROGRESS**
* (bluefox) Added support for vis-2 testing

### 1.0.9 (2023-12-19)
* (foxriver76) create folder on initialization

Expand All @@ -24,7 +27,7 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46
* (foxriver76) allow re-initialization after config change

### 1.0.6 (2023-12-19)
* (foxriver76) allow to specify the `rootDir`
* (foxriver76) allow specifying the `rootDir`

### 1.0.5 (2023-12-15)
* (bluefox) Added support for vis-1 testing
Expand Down
19 changes: 18 additions & 1 deletion setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,22 @@ async function installJsController(preInstalledAdapters, cb) {
await storeOriginalFiles();
cb && cb(true);
} else {
if (preInstalledAdapters) {
for (let p = 0; p < preInstalledAdapters.length; p++) {
// if not installed
const parts = preInstalledAdapters[p].split('@');
const name = parts[0];
const version = parts[1];
if (!fs.existsSync(`${rootDir}tmp/node_modules/${name}`)) {
await installAdapterAsync(preInstalledAdapters[p]);
} else {
const pack = require(`${rootDir}tmp/node_modules/${name}/package.json`);
if (pack.version !== version) {
await installAdapterAsync(preInstalledAdapters[p]);
}
}
}
}
setTimeout(() => {
console.log('installJsController: js-controller installed');
cb && cb(false);
Expand Down Expand Up @@ -560,8 +576,9 @@ function clearDB() {
* @param {LegacyTestingOptions} options specify attributes which should be overridden
*/
function setOptions(options) {
if (options.rootDir) {
if (options.rootDir && fs.existsSync(options.rootDir) && rootDir !== options.rootDir) {
rootDir = options.rootDir
initialize();
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/testPackageFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const expect = require('chai').expect;
const fs = require('fs');

// node_modules/@iobroker/legacy-testing/tests/testPackageFiles.js
const adapterDir = `${__dirname}/../../../../`;
const adapterDir = process.env.IOBROKER_ROOT_DIR || `${__dirname}/../../../../`;
const alternativeAdapterDir = `${__dirname}/../../../../`;

describe('Test package.json and io-package.json', () => {
it('Test package files', done => {
Expand Down Expand Up @@ -52,7 +53,7 @@ describe('Test package.json and io-package.json', () => {
console.log();
}

expect(fs.existsSync(`${adapterDir}/README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.').to.be.true;
expect(fs.existsSync(`${adapterDir}/README.md`) || fs.existsSync(`${alternativeAdapterDir}/README.md`), 'ERROR: README.md needs to exist! Please create one with description, detail information and changelog. English is mandatory.').to.be.true;

if (!ioPackage.common.titleLang || typeof ioPackage.common.titleLang !== 'object') {
console.log('WARNING: titleLang is not existing in io-package.json. Please add');
Expand Down Expand Up @@ -85,7 +86,7 @@ describe('Test package.json and io-package.json', () => {
}

const licenseFileExists = fs.existsSync(`${adapterDir}/LICENSE`);
const fileContentReadme = fs.readFileSync(`${adapterDir}/README.md`, 'utf8');
const fileContentReadme = fs.existsSync(`${alternativeAdapterDir}/README.md`) ? fs.readFileSync(`${alternativeAdapterDir}/README.md`, 'utf8') : fs.readFileSync(`${adapterDir}/README.md`, 'utf8');

if (!fileContentReadme.includes('## Changelog')) {
console.log('Warning: The README.md should have a section ## Changelog');
Expand Down

0 comments on commit 1f192d7

Please sign in to comment.