Skip to content

Commit

Permalink
Chore: using static test entry
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Apr 24, 2021
1 parent 9177859 commit 21e5b7d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
9 changes: 8 additions & 1 deletion .eslintrc
Expand Up @@ -8,6 +8,13 @@
"func-names": 0,
"func-style": 0,
"prefer-arrow-callback": 0,
"linebreak-style": 0
"linebreak-style": 0,
"max-len": ["error", {
"comments": 800,
"code": 120,
"ignoreUrls": true,
"ignoreTemplateLiterals": true,
"ignoreStrings": true
} ]
}
}
21 changes: 2 additions & 19 deletions bin/pack-tests.js
@@ -1,33 +1,16 @@
#!./node_modules/.bin/babel-node
import os from 'os';
import path from 'path';
import { fill } from 'myrmidon';

import { rollup } from 'rollup';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
import multi from '@rollup/plugin-multi-entry';
import babel from '@rollup/plugin-babel';
import fs from 'fs-extra';
import uuid from 'uuid';

const isMain = !module.parent;

async function replaceWithTemplate(templatePath, context, destPath) {
const content = await fs.readFile(templatePath);
const filled = fill(content.toString(), context);
const backupPath = path.resolve(os.tmpdir(), uuid.v4());

await fs.move(destPath, backupPath);
await fs.writeFile(destPath, filled);

return backupPath;
}

async function run() {
try {
const backup = await replaceWithTemplate(path.resolve('tests/entry.static.js'), { entry: '../tmp/package/lib' }, path.resolve('tests/entry.js'));

try {
const bundle = await rollup({
input : 'tests/**/*test.js',
Expand Down Expand Up @@ -55,7 +38,7 @@ async function run() {
console.error('ROLLUP ERROR');
throw error;
} finally {
await fs.move(backup, path.resolve('tests/entry.js'), { overwrite: true });
// await fs.move(backup, path.resolve('tests/entry.js'), { overwrite: true });
}
console.log('Done');
process.exit(0);
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -71,7 +71,6 @@
"jscpd": "^3.3.25",
"lockfile-lint": "^4.6.2",
"mocha": "^6.2.3",
"myrmidon": "^1.4.5",
"nyc": "^14.1.1",
"rollup": "^2.45.2",
"semantic-release": "^17.4.2",
Expand Down
6 changes: 3 additions & 3 deletions tests/entry.js
Expand Up @@ -5,8 +5,8 @@ const entry = process.env.ENTRY && path.resolve(process.env.ENTRY)
|| isBuild && path.resolve(__dirname, '../lib')
|| path.resolve(__dirname, '../src');

module.exports = require(entry);
export default require(entry);

module.exports._load = function (relPath) {
export function _load(relPath) {
return require(path.join(entry, relPath));
};
}
7 changes: 0 additions & 7 deletions tests/entry.static.js

This file was deleted.

0 comments on commit 21e5b7d

Please sign in to comment.