mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-12 03:06:05 +09:00
Clean up the oopsie. Rebuild the blank exercises.
This commit is contained in:
+20
-16
@@ -1,26 +1,30 @@
|
||||
'use strict';
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
const readPkg = require('read-pkg');
|
||||
|
||||
module.exports = opts => {
|
||||
return findUp('package.json', opts).then(fp => {
|
||||
if (!fp) {
|
||||
return {};
|
||||
}
|
||||
module.exports = async options => {
|
||||
const filePath = await findUp('package.json', options);
|
||||
|
||||
return readPkg(fp, opts).then(pkg => ({pkg, path: fp}));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = opts => {
|
||||
const fp = findUp.sync('package.json', opts);
|
||||
|
||||
if (!fp) {
|
||||
return {};
|
||||
if (!filePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
pkg: readPkg.sync(fp, opts),
|
||||
path: fp
|
||||
packageJson: await readPkg({...options, cwd: path.dirname(filePath)}),
|
||||
path: filePath
|
||||
};
|
||||
};
|
||||
|
||||
module.exports.sync = options => {
|
||||
const filePath = findUp.sync('package.json', options);
|
||||
|
||||
if (!filePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
packageJson: readPkg.sync({...options, cwd: path.dirname(filePath)}),
|
||||
path: filePath
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user