Skip to content

Commit

Permalink
(refactor): use path constants instead of custom resolveApp (#402)
Browse files Browse the repository at this point in the history
- and use ensureDistFolder since that exists now
- and use async readJSON since most were converted before
  • Loading branch information
agilgur5 authored and jaredpalmer committed Dec 29, 2019
1 parent f338613 commit a38041f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
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
@@ -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
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 @@ -463,7 +463,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

0 comments on commit a38041f

Please sign in to comment.