-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: syncing multiple files based on workspaces/packages field (#11)
- Loading branch information
Showing
10 changed files
with
333 additions
and
67 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createGlobber } from '../globber' | ||
|
||
test('returns the current directory as a match', async () => { | ||
const result = await createGlobber().globPackageFiles(process.cwd()) | ||
expect(result).toHaveLength(1) | ||
expect(result[0]).toBe(process.cwd() + '/package.json') | ||
}) |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import glob from 'glob' | ||
import * as path from 'path' | ||
import { uniq } from './util' | ||
|
||
/** | ||
* Globber interface. | ||
*/ | ||
export interface IGlobber { | ||
/** | ||
* Globs for package.json files. | ||
* | ||
* @param pattern | ||
*/ | ||
globPackageFiles(pattern: string): Promise<Array<string>> | ||
} | ||
|
||
/** | ||
* Creates a globber. | ||
*/ | ||
export function createGlobber() { | ||
return { | ||
globPackageFiles(pattern: string) { | ||
return new Promise<Array<string>>((resolve, reject) => | ||
glob( | ||
path.join(pattern, 'package.json'), | ||
(err, matches) => (err ? reject(err) : resolve(uniq(matches))) | ||
) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.