Skip to content

Commit 39ec0a5

Browse files
Hristo HristovHristo Hristov
authored andcommitted
fix: race condition problem update
1 parent 4d312d7 commit 39ec0a5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/cli/lib/templates/ReactTemplate.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ export class ReactTemplate implements Template {
110110
const igResPath = path.join(projectPath, this.igniteResources);
111111

112112
if (fs.existsSync(igResPath)) {
113-
let igniteuiResFile = fs.readFileSync(igResPath, "utf8");
113+
const fd = fs.openSync(igResPath, fs.constants.O_RDWR);
114+
let igniteuiResFile = fs.readFileSync(fd, "utf8");
114115
const freeVersionPath = "ignite-ui/";
115116
const fullVersionPath = "@infragistics/ignite-ui-full/en/";
116117
const dvPath = "@infragistics/ignite-ui-full/en/js/infragistics.dv.js";
@@ -124,17 +125,15 @@ export class ReactTemplate implements Template {
124125
igniteuiResFile = igniteuiResFile.replace("-lite", "");
125126
}
126127

127-
const fd = fs.openSync(igResPath, fs.constants.O_WRONLY | fs.constants.O_TRUNC);
128+
fs.ftruncateSync(fd, 0);
128129
fs.writeSync(fd, igniteuiResFile);
129-
fs.closeSync(fd);
130130
}
131131

132132
if (dvDep && !igniteuiResFile.includes(dvPath)) {
133-
const fd = fs.openSync(igResPath, fs.constants.O_WRONLY | fs.constants.O_APPEND);
134133
fs.writeSync(fd, `\r\n// Ignite UI Charts Required JavaScript File\r\nimport "${dvPath}";\r\n`);
135-
fs.closeSync(fd);
136134
}
137135

136+
fs.closeSync(fd);
138137
} else {
139138
Util.log(`igniteuiResources.js file NOT found!`);
140139
}

0 commit comments

Comments
 (0)