Skip to content

Commit

Permalink
chore: use replace-in-file
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Oct 3, 2018
1 parent e34a3ce commit d289e75
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"netlify": "^2.0.1",
"node-static": "^0.7.8",
"phantomjs-prebuilt": "^2.1.12",
"replace-in-file": "^3.4.2",
"semver": "^5.3.0",
"sinon": "^1.17.6",
"webpack": "^1.13.2",
Expand Down
19 changes: 15 additions & 4 deletions scripts/netlify-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict';
/* eslint-disable no-console */
const execa = require('execa');
const replace = require('replace-in-file');
const NetlifyAPI = require('netlify');

const client = new NetlifyAPI(process.env.NETLIFY_API_KEY);
Expand All @@ -26,7 +27,11 @@ execa('yarn', ['build'])
.then(() => execa('cp', ['-r', 'examples', 'netlify-dist']))
.then(() => execa('mv', ['netlify-dist/examples/index.html', 'netlify-dist']))
.then(() =>
execa.shell(`sed -i "" 's|href=\"../|href=\"./|g' netlify-dist/index.html`)
replace({
files: 'netlify-dist/index.html',
from: /href="\.\./g,
to: 'href=".'
})
)
.then(() => execa('mkdir', ['-p', 'netlify-dist/test']))
.then(() =>
Expand All @@ -40,9 +45,15 @@ execa('yarn', ['build'])
)
.then(() => execa('cp', ['-r', 'dist', 'netlify-dist']))
.then(() =>
execa.shell(
`sed -i "" 's|https://cdn.jsdelivr.net/autocomplete.js/0|../dist|g' netlify-dist/examples/basic.html netlify-dist/examples/basic_angular.html netlify-dist/examples/basic_jquery.html`
)
replace({
files: [
'netlify-dist/examples/basic.html',
'netlify-dist/examples/basic_angular.html',
'netlify-dist/examples/basic_jquery.html'
],
from: /https:\/\/cdn.jsdelivr.net\/autocomplete.js\/0/g,
to: '../dist'
})
)
.then(() =>
client.deploy(process.env.NETLIFY_SITE_ID, 'netlify-dist', {
Expand Down
Loading

0 comments on commit d289e75

Please sign in to comment.