@ovipakla/gm-cli 1.0.3 ā 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app.js +6 -3
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -78,9 +78,11 @@ program.command('sync')
|
|
|
78
78
|
program.command('install')
|
|
79
79
|
.description('Install dependencies listed in package-gm.json to gm_modules folder')
|
|
80
80
|
.option('-c, --clean', 'remove existing gm_modules')
|
|
81
|
+
.option('-s, --shallow', 'git clone will use depth=1 branch=REVISION')
|
|
81
82
|
.action(function() {
|
|
82
83
|
const options = this.opts();
|
|
83
84
|
const clean = options.clean !== undefined;
|
|
85
|
+
const shallow = options.shallow !== undefined;
|
|
84
86
|
const packageJsonPath = 'package-gm.json';
|
|
85
87
|
const modulesDir = 'gm_modules';
|
|
86
88
|
|
|
@@ -96,23 +98,24 @@ program.command('install')
|
|
|
96
98
|
Object.entries(dependencies).forEach(([key, dependency]) => {
|
|
97
99
|
console.log(`\nš¦ļø Install ${key}\n===========${"=".repeat(key.length)}`)
|
|
98
100
|
const modulePath = path.join(modulesDir, key);
|
|
101
|
+
const cloneOptions = shallow ? `--depth 1 --branch ${dependency.revision}` : ''
|
|
99
102
|
if (fs.existsSync(modulePath)) {
|
|
100
103
|
try {
|
|
101
104
|
execSync('git rev-parse --is-inside-work-tree', { cwd: modulePath, stdio: 'ignore' });
|
|
102
105
|
console.log(`š Syncing ${modulePath} to revision ${dependency.revision}`);
|
|
103
106
|
execSync('git reset --hard HEAD', { cwd: modulePath, stdio: 'inherit' });
|
|
104
|
-
execSync('git clean -fdx
|
|
107
|
+
execSync('git clean -fdx', { cwd: modulePath, stdio: 'inherit' });
|
|
105
108
|
execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
|
|
106
109
|
} catch (error) {
|
|
107
110
|
console.log(`šļø Removing ${modulePath} because it's not a git repository`);
|
|
108
111
|
fs.rmSync(modulePath, { recursive: true, force: true });
|
|
109
112
|
console.log(`š§ Initializing ${modulePath} to revision ${dependency.revision}`);
|
|
110
|
-
execSync(`git clone ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
|
|
113
|
+
execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
|
|
111
114
|
execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
|
|
112
115
|
}
|
|
113
116
|
} else {
|
|
114
117
|
console.log(`š§ Initializing ${modulePath} to revision ${dependency.revision}`);
|
|
115
|
-
execSync(`git clone ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
|
|
118
|
+
execSync(`git clone ${cloneOptions} ${dependency.remote} ${modulePath}`, { stdio: 'inherit' });
|
|
116
119
|
execSync(`git checkout ${dependency.revision}`, { cwd: modulePath, stdio: 'inherit' });
|
|
117
120
|
}
|
|
118
121
|
});
|