-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update asap src unit tests to use
mock-tmp
- Loading branch information
Showing
2 changed files
with
37 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
let { join } = require('path') | ||
let { existsSync } = require('fs') | ||
|
||
module.exports = function asapSrc () { | ||
module.exports = function asapSrc (params = {}) { | ||
let { _testing } = params | ||
let dirname = _testing ? _testing : __dirname | ||
// Inventory running as an arc/arc dependency (most common use case) | ||
let src = join(process.cwd(), 'node_modules', '@architect', 'asap', 'src') | ||
if (existsSync(src)) return src | ||
|
||
// Inventory running in arc/arc as a global install | ||
let global = join(__dirname, '..', '..', '..', 'asap', 'src') | ||
let global = join(dirname, '..', '..', '..', 'asap', 'src') | ||
if (existsSync(global)) return global | ||
|
||
// Inventory running from a local (symlink) context (usually testing/dev) | ||
let local = join(__dirname, '..', '..', 'node_modules', '@architect', 'asap', 'src') | ||
let local = join(dirname, '..', '..', 'node_modules', '@architect', 'asap', 'src') | ||
if (existsSync(local)) return local | ||
|
||
try { | ||
return require.resolve('@architect/asap') | ||
} | ||
catch (err) { | ||
catch { | ||
/* istanbul ignore next */ | ||
throw Error('Cannot find ASAP module!') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters