Skip to content

Commit

Permalink
feat(state): allows root scope to be set as null
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed Apr 24, 2019
1 parent ee809f5 commit 87e80b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
23 changes: 13 additions & 10 deletions src/state/paths/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ export default async function paths(opts: IPathsOpts): Promise<IPaths> {

// has to to called after load to wait for scope options to modify state
const rootDir = state.get('root');
const root = await getRootPaths(
rootDir || path.join(self.directory, '../')
).catch(async (err) => {
// don't fail if root directory wasn't explicitly passed via options,
// just set as null
if (!rootDir) return null;
const root =
rootDir === null
? null
: await getRootPaths(rootDir || path.join(self.directory, '../')).catch(
async (err) => {
// don't fail if root directory wasn't explicitly passed via options,
// just set as null
if (!rootDir) return null;

return wrap.rejects(err, {
message: `root scope couldn't be retrieved: ${state.get('root')}`
});
});
return wrap.rejects(err, {
message: `root scope couldn't be retrieved: ${state.get('root')}`
});
}
);

return {
...self,
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export interface IBaseOptions extends ICoreOptions {
}

export interface IScopeOptions extends ICoreOptions {
root?: string;
root?: string | null;
children?: IOfType<string>;
}

0 comments on commit 87e80b9

Please sign in to comment.