projectinfo/ts/projectinfo.classes.npm.ts

33 lines
989 B
TypeScript
Raw Normal View History

2022-04-18 20:16:46 +00:00
import * as plugins from './projectinfo.plugins.js';
2016-11-26 13:45:56 +00:00
export class ProjectinfoNpm {
2018-09-02 12:21:05 +00:00
isNpm: boolean = false;
packageJson: any;
name: string;
version: string;
status: string;
license: string;
git: plugins.smartstring.GitRepo;
2016-02-22 23:58:33 +00:00
2018-09-02 12:21:05 +00:00
constructor(cwdArg: string, optionsArg: { gitAccessToken?: string } = {}) {
let resolvedCwd = plugins.path.resolve(cwdArg);
if (plugins.smartfile.fs.fileExists(plugins.path.join(resolvedCwd, 'package.json'))) {
this.isNpm = true;
this.packageJson = plugins.smartfile.fs.toObjectSync(
plugins.path.join(resolvedCwd, 'package.json'),
'json'
);
this.name = this.packageJson.name;
this.version = this.packageJson.version;
this.status = 'ok';
this.license = this.packageJson.license;
if (this.packageJson.repository) {
this.git = new plugins.smartstring.GitRepo(
this.packageJson.repository.url,
optionsArg.gitAccessToken
);
}
}
}
2016-11-26 13:45:56 +00:00
}