-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2281ef3
commit 52935f6
Showing
7 changed files
with
49 additions
and
54 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
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 |
---|---|---|
@@ -1,39 +1,32 @@ | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = writeBuildFile; | ||
|
||
var _fs = require('fs'); | ||
|
||
var _fs2 = _interopRequireDefault(_fs); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
/** | ||
* Writes into a file asynchronously | ||
* @param {String} fileName the name of the file to write to | ||
* @param {String} fileData the data to be written | ||
*/ | ||
function writeBuildFile(fileName, fileData) { | ||
fs.stat('./build', (err, stats) => { | ||
_fs2.default.stat('./build', (err, stats) => { | ||
if (err) { | ||
fs.mkdir('./build', err => { | ||
_fs2.default.mkdir('./build', err => { | ||
if (err) { | ||
throw new Error(err); | ||
} | ||
fs.writeFileSync(`./build/${fileName}`, fileData); | ||
_fs2.default.writeFileSync(`./build/${fileName}`, fileData); | ||
}); | ||
} else { | ||
fs.writeFileSync(`./build/${fileName}`, fileData); | ||
} | ||
}); | ||
} | ||
|
||
function readFile(filePath, cb) { | ||
fs.stat(filePath, (err, stats) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (stats.isFile) { | ||
fs.readFile(filePath, 'utf-8', (err, data) => { | ||
if (err) { | ||
return cb(err); | ||
} | ||
return cb(null, data); | ||
}); | ||
_fs2.default.writeFileSync(`./build/${fileName}`, fileData); | ||
} | ||
}); | ||
} | ||
|
||
module.exports = { | ||
writeBuildFile, | ||
readFile | ||
}; | ||
} |
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
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
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
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
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