diff --git a/ember-addon-main.js b/ember-addon-main.js index b2cb937d..b1e70bb4 100644 --- a/ember-addon-main.js +++ b/ember-addon-main.js @@ -1,6 +1,8 @@ 'use strict'; const fs = require('fs'); +const mkdirp = require('mkdirp'); +const copyFileSync = require('fs-copy-file-sync'); const path = require('path'); const utils = require('./utils'); const addDependencyTracker = require("./addDependencyTracker"); @@ -82,7 +84,6 @@ export default setComponentTemplate(TEMPLATE, CLASS);`; let outputPath = path.join(this.outputPath, possibleJSPath); - // TODO: check for compat with Node 8 (recursive may only be present in 10+) // TODO: don't speculatively mkdirSync (likely do in a try/catch with ENOENT) fs.mkdirSync(path.dirname(outputPath), { recursive: true }); @@ -98,10 +99,9 @@ export default setComponentTemplate(TEMPLATE, CLASS);`; return; } - // TODO: check for compat with Node 8 (recursive may only be present in 10+) // TODO: don't speculatively mkdirSync (likely do in a try/catch with ENOENT) - fs.mkdirSync(path.dirname(outputPath), { recursive: true }); - fs.copyFileSync(inputPath, outputPath); + mkdirp.sync(path.dirname(outputPath)); + copyFileSync(inputPath, outputPath); }) } } diff --git a/package.json b/package.json index a0a212e2..2573f6f6 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,10 @@ "dependencies": { "broccoli-persistent-filter": "^2.3.1", "broccoli-plugin": "^2.0.0", + "fs-copy-file-sync": "^1.1.1", "hash-for-dep": "^1.5.1", "json-stable-stringify": "^1.0.1", + "mkdirp": "^0.5.1", "strip-bom": "^3.0.0", "walk-sync": "^1.1.3" }, diff --git a/yarn.lock b/yarn.lock index 190d98d2..ab7514d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4146,6 +4146,11 @@ from2@^2.1.1: inherits "^2.0.1" readable-stream "^2.0.0" +fs-copy-file-sync@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/fs-copy-file-sync/-/fs-copy-file-sync-1.1.1.tgz#11bf32c096c10d126e5f6b36d06eece776062918" + integrity sha512-2QY5eeqVv4m2PfyMiEuy9adxNP+ajf+8AR05cEi+OAzPcOj90hvFImeZhTmKLBgSd9EvG33jsD7ZRxsx9dThkQ== + fs-extra@^0.24.0: version "0.24.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.24.0.tgz#d4e4342a96675cb7846633a6099249332b539952"