Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(refactor): use path constants instead of custom resolveApp #402

Merged
merged 1 commit into from
Dec 29, 2019
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
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();
jaredpalmer marked this conversation as resolved.
Show resolved Hide resolved
const promise = writeCjsEntryFile(opts.name).catch(logError);
logger(promise, 'Creating entry file');
} catch (e) {
Expand Down