submodule-version 1.1.0 → 1.1.2

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.
Files changed (2) hide show
  1. package/index.js +20 -14
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -53,12 +53,23 @@ const getName = url => {
53
53
  return parts[parts.length - 1];
54
54
  };
55
55
 
56
+ const checkout = (url, version) => {
57
+ const module = isGitUrl(url) ? `${config.dir}/${getName(url)}` : url;
58
+ logger('checkout', module);
59
+ try {
60
+ execSync(`git -C ${module} checkout ${version} -q`);
61
+ } catch {
62
+ abort('Checkout failded');
63
+ };
64
+ };
65
+
56
66
  const install = (url, version, location) => {
57
67
  const name = getName(url);
58
68
  const targetLocation = path.join(location, name);
59
- const gitCmd = `git submodule add -b ${version} ${url} ${targetLocation}`;
69
+ const gitCmd = `git submodule add ${url} ${targetLocation}`;
60
70
  try {
61
71
  execSync(gitCmd);
72
+ checkout(url, version);
62
73
  } catch {
63
74
  abort(url, 'Is not a git repo');
64
75
  }
@@ -101,20 +112,15 @@ const computeErrors = () => {
101
112
 
102
113
  const validate = (sv, name) => {
103
114
  buildGraph(sv, name, config.dir);
104
- logger('Everything is up to date.');
115
+
105
116
  const errors = computeErrors();
106
- if (!errors) return;
107
- abort(errors);
108
- };
117
+ if (errors) abort(errors);
109
118
 
110
- const checkoutModule = (url, version) => {
111
- const module = isGitUrl(url) ? `${config.dir}/${getName(url)}` : url;
112
- logger('checkout', module);
113
- try {
114
- execSync(`git -C ${module} checkout ${version} -q`);
115
- } catch {
116
- abort('Checkout failded');
117
- };
119
+ Object.entries(graph).forEach(([url, versions]) => {
120
+ checkout(`${config.dir}/${url}`, versions[0]);
121
+ });
122
+
123
+ logger('Everything is up to date.');
118
124
  };
119
125
 
120
126
  const validationCommand = () => {
@@ -135,7 +141,7 @@ const installCommand = arg => {
135
141
  const installedDep = projectJSON.sv?.[gitaddress];
136
142
 
137
143
  if (installedDep && installedDep !== version) {
138
- checkoutModule(gitaddress, version);
144
+ checkout(gitaddress, version);
139
145
  }
140
146
 
141
147
  const sv = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "submodule-version",
3
3
  "description": "Git <S>ubmodule <V>ersioning tool",
4
- "version": "1.1.0",
4
+ "version": "1.1.2",
5
5
  "bin": {
6
6
  "sv": "index.js"
7
7
  },