Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
(refactor): use path constants instead of custom resolveApp
- and use ensureDistFolder since that exists now
- and use async readJSON since most were converted before
  • Loading branch information
agilgur5 committed Dec 28, 2019
commit 6404dcc4163ecc25ea3bdde39f125f8cc41b22d7
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolveApp } from './utils';

export const paths = {
appPackageJson: resolveApp('package.json'),
tsconfigJson: resolveApp('tsconfig.json'),
testsSetup: resolveApp('test/setupTests.ts'),
appRoot: resolveApp('.'),
appSrc: resolveApp('src'),
Expand Down
9 changes: 2 additions & 7 deletions src/createRollupConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
safeVariableName,
safePackageName,
external,
resolveApp,
} from './utils';
import { safeVariableName, safePackageName, external } from './utils';
import { paths } from './constants';
import { RollupOptions } from 'rollup';
import { terser } from 'rollup-plugin-terser';
Expand Down Expand Up @@ -50,7 +45,7 @@ export async function createRollupConfig(

let tsconfigJSON;
try {
tsconfigJSON = fs.readJSONSync(resolveApp('tsconfig.json'));
tsconfigJSON = await fs.readJSON(paths.tsconfigJson);
} catch (e) {}

return {
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const prog = sade('tsdx');
let appPackageJson: PackageJson;

try {
appPackageJson = fs.readJSONSync(resolveApp('package.json'));
appPackageJson = fs.readJSONSync(paths.appPackageJson);
} catch (e) {}

// check for custom tsdx.config.js
Expand Down Expand Up @@ -464,7 +464,7 @@ prog
const logger = await createProgressEstimator();
if (opts.format.includes('cjs')) {
try {
await util.promisify(mkdirp)(resolveApp('./dist'));
await ensureDistFolder();
const promise = writeCjsEntryFile(opts.name).catch(logError);
logger(promise, 'Creating entry file');
} catch (e) {
Expand Down