-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial caching of disc-saved packages
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { promisify } from 'util'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as os from 'os'; | ||
import artifactoryService from './artifactory-service'; | ||
|
||
const readdir = promisify(fs.readdir); | ||
|
||
export default { | ||
tmpDir: path.join(os.homedir(), '.npmfrog', 'package-cache'), | ||
|
||
// tslint:disable-next-line:typedef | ||
async fillCacheFromDisc() { | ||
const promises = []; | ||
const scopes = await readdir(this.tmpDir); | ||
for (const scope of scopes) { | ||
const packages = await readdir(path.join(this.tmpDir, scope)); | ||
for (const packageName of packages) { | ||
const versions = await readdir(path.join(this.tmpDir, scope, packageName)); | ||
for (const version of versions) { | ||
artifactoryService | ||
.getPackageDetail({ scope, packageName, version }) | ||
.then(() => { | ||
console.log(`caching ${scope}/${packageName}@${version} from disc`); | ||
}) | ||
.catch(() => { | ||
console.warn( | ||
`${scope}/${packageName}@${version} on disc seems to be outdated. Is will not be cached.`, | ||
); | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
}; |
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